1616use Doctrine \DBAL \Schema \Schema ;
1717use Symfony \Component \Lock \Exception \InvalidArgumentException ;
1818use Symfony \Component \Lock \Exception \LockConflictedException ;
19- use Symfony \Component \Lock \Exception \LockExpiredException ;
2019use Symfony \Component \Lock \Exception \NotSupportedException ;
2120use Symfony \Component \Lock \Key ;
2221use Symfony \Component \Lock \StoreInterface ;
3635 */
3736class PdoStore implements StoreInterface
3837{
38+ use ExpiringStoreTrait;
39+
<
2E0F
/tr>3940 private $ conn ;
4041 private $ dsn ;
4142 private $ driver ;
@@ -123,11 +124,6 @@ public function save(Key $key)
123124
124125 try {
125126 $ 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- }
129-
130- return ;
131127 } catch (DBALException $ e ) {
132128 // the lock is already acquired. It could be us. Let's try to put off.
133129 $ this ->putOffExpiration ($ key , $ this ->initialTtl );
@@ -136,13 +132,11 @@ public function save(Key $key)
136132 $ this ->putOffExpiration ($ key , $ this ->initialTtl );
137133 }
138134
139- if ($ key ->isExpired ()) {
140- throw new LockExpiredException (sprintf ('Failed to store the "%s" lock. ' , $ key ));
141- }
142-
143135 if ($ this ->gcProbability > 0 && (1.0 === $ this ->gcProbability || (random_int (0 , PHP_INT_MAX ) / PHP_INT_MAX ) <= $ this ->gcProbability )) {
144136 $ this ->prune ();
145137 }
138+
139+ $ this ->checkNotExpired ($ key );
146140 }
147141
148142 /**
@@ -178,9 +172,7 @@ public function putOffExpiration(Key $key, $ttl)
178172 throw new LockConflictedException ();
179173 }
180174
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- }
175+ $ this ->checkNotExpired ($ key );
184176 }
185177
186178 /**
@@ -294,7 +286,7 @@ public function createTable(): void
294286 }
295287
296288 /**
297- * Cleanups the table by removing all expired locks.
289+ * Cleans up the table by removing all expired locks.
298290 */
299291 private function prune (): void
300292 {
0 commit comments