16
16
use Doctrine \DBAL \Schema \Schema ;
17
17
use Symfony \Component \Lock \Exception \InvalidArgumentException ;
18
18
use Symfony \Component \Lock \Exception \LockConflictedException ;
19
- use Symfony \Component \Lock \Exception \LockExpiredException ;
20
19
use Symfony \Component \Lock \Exception \NotSupportedException ;
21
20
use Symfony \Component \Lock \Key ;
22
21
use Symfony \Component \Lock \StoreInterface ;
36
35
*/
37
36
class PdoStore implements StoreInterface
38
37
{
38
+ use ExpiringStoreTrait;
39
+
39
40
private $ conn ;
40
41
private $ dsn ;
41
42
private $ driver ;
@@ -123,9 +124,7 @@ public function save(Key $key)
123
124
124
125
try {
125
126
$ stmt ->execute ();
126
- if ($ key ->isExpired ()) {
127
- throw new LockExpiredException (sprintf ('Failed to put off the expiration of the "%s" lock within the specified time. ' , $ key ));
128
- }
127
+ $ this ->checkNotExpired ($ key );
129
128
130
129
return ;
131
130
} catch (DBALException $ e ) {
@@ -136,13 +135,11 @@ public function save(Key $key)
136
135
$ this ->putOffExpiration ($ key , $ this ->initialTtl );
137
136
}
138
137
139
- if ($ key ->isExpired ()) {
140
- throw new LockExpiredException (sprintf ('Failed to store the "%s" lock. ' , $ key ));
141
- }
142
-
143
138
if ($ this ->gcProbability > 0 && (1.0 === $ this ->gcProbability || (random_int (0 , PHP_INT_MAX ) / PHP_INT_MAX ) <= $ this ->gcProbability )) {
144
139
$ this ->prune ();
145
140
}
141
+
142
+ $ this ->checkNotExpired ($ key );
146
143
}
147
144
148
145
/**
@@ -178,9 +175,7 @@ public function putOffExpiration(Key $key, $ttl)
178
175
throw new LockConflictedException ();
179
176
}
180
177
181
- if ($ key ->isExpired ()) {
182
- throw new LockExpiredException (sprintf ('Failed to put off the expiration of the "%s" lock within the specified time. ' , $ key ));
183
- }
178
+ $ this ->checkNotExpired ($ key );
184
179
}
185
180
186
181
/**
0 commit comments