Skip to content

Commit 8f5d0bd

Browse files
committed
followup: remove ExpirableStoreInterface
1 parent 09fadd2 commit 8f5d0bd

16 files changed

+35
-237
lines changed

src/Symfony/Component/Lock/BlockingStoreInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface BlockingStoreInterface
3030
public function waitAndSave(Key $key);
3131

3232
/**
33-
* Check if the store can wait until a key becomes free before storing the resource.
33+
* Checks if the store can wait until a key becomes free before storing the resource.
3434
*/
3535
public function supportsWaitAndSave(): bool;
3636
}

src/Symfony/Component/Lock/CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ CHANGELOG
55
-----
66

77
* added InvalidTtlException
8-
* deprecated `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface`, `Symfony\Component\Lock\PersistStoreInterface`
9-
and `Symfony\Component\Lock\ExpiringStoreInterface`
8+
* deprecated `Symfony\Component\Lock\StoreInterface` in favor of `Symfony\Component\Lock\BlockingStoreInterface` and `Symfony\Component\Lock\PersistStoreInterface`
109

1110
4.2.0
1211
-----

src/Symfony/Component/Lock/ExpiringStoreInterface.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/Symfony/Component/Lock/Lock.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function acquire($blocking = false)
7272
try {
7373
if ($blocking) {
7474
if (!($this->store instanceof StoreInterface) && !($this->store instanceof BlockingStoreInterface && $this->store->supportsWaitAndSave())) {
75-
throw new NotSupportedException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this->store)));
75+
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this->store)));
7676
}
7777
$this->store->waitAndSave($this->key);
7878
} else {
@@ -125,9 +125,7 @@ public function refresh($ttl = null)
125125

126126
try {
127127
$this->key->resetLifetime();
128-
if ($this->store instanceof StoreInterface || ($this->store instanceof ExpiringStoreInterface && $this->store->supportsPutOffExpiration())) {
129-
$this->store->putOffExpiration($this->key, $ttl);
130-
}
128+
$this->store->putOffExpiration($this->key, $ttl);
131129
$this->dirty = true;
132130

133131
if ($this->key->isExpired()) {

src/Symfony/Component/Lock/PersistStoreInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Lock\Exception\LockAcquiringException;
1515
use Symfony\Component\Lock\Exception\LockConflictedException;
1616
use Symfony\Component\Lock\Exception\LockReleasingException;
17+
use Symfony\Component\Lock\Exception\NotSupportedException;
1718

1819
/**
1920
* @author Jérémy Derussé <jeremy@derusse.com>
@@ -41,4 +42,13 @@ public function delete(Key $key);
4142
* @return bool
4243
*/
4344
public function exists(Key $key);
45+
46+
/**
47+
* Extends the TTL of a resource.
48+
*
49+
* @param float $ttl amount of seconds to keep the lock in the store
50+
*
51+
* @throws LockConflictedException
52+
*/
53+
public function putOffExpiration(Key $key, $ttl);
4454
}

src/Symfony/Component/Lock/Store/CombinedStore.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
use Psr\Log\LoggerAwareInterface;
1515
use Psr\Log\LoggerAwareTrait;
1616
use Psr\Log\NullLogger;
17-
use Symfony\Component\Lock\BlockingStoreInterface;
1817
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1918
use Symfony\Component\Lock\Exception\LockConflictedException;
2019
use Symfony\Component\Lock\Exception\NotSupportedException;
21-
use Symfony\Component\Lock\ExpiringStoreInterface;
2220
use Symfony\Component\Lock\Key;
2321
use Symfony\Component\Lock\PersistStoreInterface;
2422
use Symfony\Component\Lock\StoreInterface;
@@ -29,7 +27,7 @@
2927
*
3028
* @author Jérémy Derussé <jeremy@derusse.com>
3129
*/
32-
class CombinedStore implements PersistStoreInterface, BlockingStoreInterface, LoggerAwareInterface, StoreInterface
30+
class CombinedStore implements StoreInterface, PersistStoreInterface, LoggerAwareInterface
3331
{
3432
use LoggerAwareTrait;
3533
use ExpiringStoreTrait;
@@ -111,14 +109,9 @@ public function putOffExpiration(Key $key, $ttl)
111109
{
112110
$successCount = 0;
113111
$failureCount = 0;
114-
115112
$storesCount = \count($this->stores);
116113
$expireAt = microtime(true) + $ttl;
117114

118-
if (false === $this->supportsPutOffExpiration()) {
119-
throw new NotSupportedException();
120-
}
121-
122115
foreach ($this->stores as $store) {
123116
try {
124117
if (0.0 >= $adjustedTtl = $expireAt - microtime(true)) {
@@ -127,10 +120,7 @@ public function putOffExpiration(Key $key, $ttl)
127120
break;
128121
}
129122

130-
if ($store instanceof ExpiringStoreInterface && $store->supportsPutOffExpiration()) {
131-
$store->putOffExpiration($key, $adjustedTtl);
132-
}
133-
123+
$store->putOffExpiration($key, $adjustedTtl);
134124
++$successCount;
135125
} catch (\Exception $e) {
136126
$this->logger->warning('One store failed to put off the expiration of the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]);
@@ -197,20 +187,6 @@ public function exists(Key $key)
197187
return false;
198188
}
199189

200-
/**
201-
* {@inheritdoc}
202-
*/
203-
public function supportsPutOffExpiration(): bool
204-
{
205-
foreach ($this->stores as $store) {
206-
if ($store instanceof ExpiringStoreInterface && $store->supportsPutOffExpiration()) {
207-
return true;
208-
}
209-
}
210-
211-
return false;
212-
}
213-
214190
/**
215191
* {@inheritdoc}
216192
*/

src/Symfony/Component/Lock/Store/FlockStore.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1616
use Symfony\Component\Lock\Exception\LockConflictedException;
1717
use Symfony\Component\Lock\Exception\LockStorageException;
18-
use Symfony\Component\Lock\Exception\NotSupportedException;
19-
use Symfony\Component\Lock\ExpiringStoreInterface;
2018
use Symfony\Component\Lock\Key;
2119
use Symfony\Component\Lock\PersistStoreInterface;
2220
use Symfony\Component\Lock\StoreInterface;
@@ -31,7 +29,7 @@
3129
* @author Romain Neutron <imprec@gmail.com>
3230
* @author Nicolas Grekas <p@tchwork.com>
3331
*/
34-
class FlockStore implements BlockingStoreInterface, ExpiringStoreInterface, PersistStoreInterface, StoreInterface
32+
class FlockStore implements StoreInterface, BlockingStoreInterface, PersistStoreInterface
3533
{
3634
private $lockPath;
3735

@@ -116,14 +114,7 @@ private function lock(Key $key, $blocking)
116114
}
117115

118116
/**
119-
* Extends the ttl of a resource.
120-
*
121-
* If the store does not support this feature it should throw a NotSupportedException.
122-
*
123-
* @param float $ttl amount of seconds to keep the lock in the store
124-
*
125-
* @throws LockConflictedException
126-
* @throws NotSupportedException
117+
* {@inheritdoc}
127118
*/
128119
public function putOffExpiration(Key $key, $ttl)
129120
{
@@ -155,9 +146,4 @@ public function exists(Key $key)
155146
{
156147
return $key->hasState(__CLASS__);
157148
}
158-
159-
public function supportsPutOffExpiration(): bool
160-
{
161-
return true;
162-
}
163149
}

src/Symfony/Component/Lock/Store/MemcachedStore.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1515
use Symfony\Component\Lock\Exception\InvalidTtlException;
1616
use Symfony\Component\Lock\Exception\LockConflictedException;
17-
use Symfony\Component\Lock\ExpiringStoreInterface;
1817
use Symfony\Component\Lock\Key;
1918
use Symfony\Component\Lock\PersistStoreInterface;
2019
use Symfony\Component\Lock\StoreInterface;
@@ -24,7 +23,7 @@
2423
*
2524
* @author Jérémy Derussé <jeremy@derusse.com>
2625
*/
27-
class MemcachedStore implements PersistStoreInterface, ExpiringStoreInterface, StoreInterface
26+
class MemcachedStore implements StoreInterface, PersistStoreInterface
2827
{
2928
use ExpiringStoreTrait;
3029

@@ -76,7 +75,7 @@ public function save(Key $key)
7675
*/
7776
public function waitAndSave(Key $key)
7877
{
79-
@trigger_error(sprintf('%s::%s has been deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', \get_class($this), __METHOD__));
78+
@trigger_error(sprintf('%s has been deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__));
8079
throw new InvalidArgumentException(sprintf('The store "%s" does not supports blocking locks.', \get_class($this)));
8180
}
8281

@@ -181,12 +180,4 @@ private function getValueAndCas(Key $key)
181180

182181
return [$value, $cas];
183182
}
184-
185-
/**
186-
* {@inheritdoc}
187-
*/
188-
public function supportsPutOffExpiration(): bool
189-
{
190-
return true;
191-
}
192183
}

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Symfony\Component\Lock\Exception\InvalidTtlException;
1919
use Symfony\Component\Lock\Exception\LockConflictedException;
2020
use Symfony\Component\Lock\Exception\NotSupportedException;
21-
use Symfony\Component\Lock\ExpiringStoreInterface;
2221
use Symfony\Component\Lock\Key;
2322
use Symfony\Component\Lock\PersistStoreInterface;
2423
use Symfony\Component\Lock\StoreInterface;
@@ -36,7 +35,7 @@
3635
*
3736
* @author Jérémy Derussé <jeremy@derusse.com>
3837
*/
39-
class PdoStore implements PersistStoreInterface, ExpiringStoreInterface, StoreInterface
38+
class PdoStore implements StoreInterface, PersistStoreInterface
4039
{
4140
use ExpiringStoreTrait;
4241

@@ -147,7 +146,7 @@ public function save(Key $key)
147146
*/
148147
public function waitAndSave(Key $key)
149148
{
150-
@trigger_error(sprintf('%s::%s has been deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', \get_class($this), __METHOD__));
149+
@trigger_error(sprintf('%s has been deprecated since Symfony 4.4 and will be removed in Symfony 5.0.', __METHOD__));
151150
throw new NotSupportedException(sprintf('The store "%s" does not supports blocking locks.', __METHOD__));
152151
}
153152

@@ -354,9 +353,4 @@ private function getCurrentTimestampStatement(): string
354353
return time();
355354
}
356355
}
357-
358-
public function supportsPutOffExpiration(): bool
359-
{
360-
return true;
361-
}
362356
}

src/Symfony/Component/Lock/Store/RedisStore.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1717
use Symfony\Component\Lock\Exception\InvalidTtlException;
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
19-
use Symfony\Component\Lock\ExpiringStoreInterface;
2019
use Symfony\Component\Lock\Key;
2120
use Symfony\Component\Lock\PersistStoreInterface;
2221
use Symfony\Component\Lock\StoreInterface;
@@ -26,7 +25,7 @@
2625
*
2726
* @author Jérémy Derussé <jeremy@derusse.com>
2827
*/
29-
class RedisStore implements PersistStoreInterface, ExpiringStoreInterface, StoreInterface
28+
class RedisStore implements StoreInterface, PersistStoreInterface
3029
{
3130
use ExpiringStoreTrait;
3231

@@ -164,12 +163,4 @@ private function getUniqueToken(Key $key): string
164163

165164
return $key->getState(__CLASS__);
166165
}
167-
168-
/**
169-
* {@inheritdoc}
170-
*/
171-
public function supportsPutOffExpiration(): bool
172-
{
173-
return true;
174-
}
175166
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy