|
18 | 18 | use Symfony\Component\Cache\Traits\RedisTrait;
|
19 | 19 |
|
20 | 20 | /**
|
21 |
| - * Stores tag id <> cache id relationship as a Redis Set, lookup on invalidation using sPOP. |
| 21 | + * Stores tag id <> cache id relationship as a Redis Set, lookup on invalidation using RENAME+SMEMBERS. |
22 | 22 | *
|
23 | 23 | * Set (tag relation info) is stored without expiry (non-volatile), while cache always gets an expiry (volatile) even
|
24 | 24 | * if not set by caller. Thus if you configure redis with the right eviction policy you can be safe this tag <> cache
|
25 | 25 | * relationship survives eviction (cache cleanup when Redis runs out of memory).
|
26 | 26 | *
|
27 | 27 | * Requirements:
|
28 | 28 | * - Client: PHP Redis or Predis
|
29 |
| - * Due to lack of RENAME support it is not recommended to use PredisCluster, instead use RedisCluster. |
| 29 | + * Note: Due to lack of RENAME support it is NOT recommended to use Cluster on Predis, instead use phpredis. |
30 | 30 | * - Server: Redis 2.8+
|
31 | 31 | * Configured with any `volatile-*` eviction policy, OR `noeviction` if it will NEVER fill up memory
|
32 | 32 | *
|
33 | 33 | * Design limitations:
|
34 | 34 | * - Max 4 billion cache keys per cache tag as limited by Redis Set datatype.
|
35 |
| - * E.g. If you use a "all" items tag for expiry instead of clear(), that limits you to 4 billion cache items as well. |
| 35 | + * E.g. If you use a "all" items tag for expiry instead of clear(), that limits you to 4 billion cache items also. |
36 | 36 | *
|
37 | 37 | * @see https://redis.io/topics/lru-cache#eviction-policies Documentation for Redis eviction policies.
|
38 | 38 | * @see https://redis.io/topics/data-types#sets Documentation for Redis Set datatype.
|
@@ -144,10 +144,7 @@ protected function doDelete(array $ids, array $tagData = []): bool
|
144 | 144 | protected function doInvalidate(array $tagIds): bool
|
145 | 145 | {
|
146 | 146 | if ($this->redis instanceof \Predis\ClientInterface && $this->redis->getConnection() instanceof ClusterInterface) {
|
147 |
| - CacheItem::log( |
148 |
| - $this->logger, |
149 |
| - 'Cluster on Predis does not support RENAME so there is a risk of race conditions on tag invalidation, please use phpredis instead.' |
150 |
| - ); |
| 147 | + CacheItem::log($this->logger, 'Cluster on Predis does not support RENAME so there is a risk of race conditions on tag invalidation, use phpredis instead.'); |
151 | 148 | $movedTagSetIds = $tagIds;
|
152 | 149 | } else {
|
153 | 150 | $movedTagSetIds = $this->renameKeys($tagIds);
|
@@ -179,13 +176,13 @@ protected function doInvalidate(array $tagIds): bool
|
179 | 176 | /**
|
180 | 177 | * Rename several keys in order to be able to operate on them without risk of race conditions.
|
181 | 178 | *
|
182 |
| - * Filters out keys that does not exists before returning new keys. |
| 179 | + * Filters out keys that does not exist before returning new keys. |
183 | 180 | *
|
184 | 181 | * @see https://redis.io/commands/rename
|
185 | 182 | *
|
186 |
| - * @param array $ids the Orginal cache id's |
| 183 | + * @param array $ids The original cache ids |
187 | 184 | *
|
188 |
| - * @return array filtered list of the valid moved keys (only those that existed) |
| 185 | + * @return array Filtered list of the valid moved keys (only those that existed) |
189 | 186 | */
|
190 | 187 | private function renameKeys(array $ids): array
|
191 | 188 | {
|
|
0 commit comments