15
15
use Predis \Connection \Aggregate \PredisCluster ;
16
16
use Predis \Connection \Aggregate \ReplicationInterface ;
17
17
use Predis \Response \Status ;
18
+ use Symfony \Component \Cache \CacheItem ;
18
19
use Symfony \Component \Cache \Exception \InvalidArgumentException ;
19
20
use Symfony \Component \Cache \Exception \LogicException ;
20
21
use Symfony \Component \Cache \Marshaller \DeflateMarshaller ;
@@ -159,6 +160,12 @@ protected function doDeleteYieldTags(array $ids): iterable
159
160
});
160
161
161
162
foreach ($ results as $ id => $ result ) {
163
+ if ($ result instanceof \RedisException) {
164
+ CacheItem::log ($ this ->logger , 'Failed to delete key "{key}": ' .$ result ->getMessage (), ['key ' => substr ($ id , \strlen ($ this ->namespace )), 'exception ' => $ result ]);
165
+
166
+ continue ;
167
+ }
168
+
162
169
try {
163
170
yield $ id => !\is_string ($ result ) || '' === $ result ? [] : $ this ->marshaller ->unmarshall ($ result );
164
171
} catch (\Exception $ e ) {
@@ -197,6 +204,8 @@ protected function doInvalidate(array $tagIds): bool
197
204
// gargage collect that set from the client side.
198
205
199
206
$ lua = <<<'EOLUA'
207
+ redis.replicate_commands()
208
+
200
209
local cursor = '0'
201
210
local id = KEYS[1]
202
211
repeat
@@ -234,14 +243,26 @@ protected function doInvalidate(array $tagIds): bool
234
243
});
235
244
236
245
$ lua = <<<'EOLUA'
246
+ redis.replicate_commands()
247
+
237
248
local id = KEYS[1]
238
249
local cursor = table.remove(ARGV)
239
250
redis.call('SREM', '{'..id..'}'..id, unpack(ARGV))
240
251
241
252
return redis.call('SSCAN', '{'..id..'}'..id, cursor, 'COUNT', 5000)
242
253
EOLUA;
243
254
244
- foreach ($ results as $ id => [$ cursor , $ ids ]) {
255
+ $ success = true ;
256
+ foreach ($ results as $ id => $ values ) {
257
+ if ($ values instanceof \RedisException) {
258
+ CacheItem::log ($ this ->logger , 'Failed to invalidate key "{key}": ' .$ result ->getMessage (), ['key ' => substr ($ id , \strlen ($ this ->namespace )), 'exception ' => $ result ]);
259
+ $ success = false ;
260
+
261
+ continue ;
262
+ }
263
+
264
+ [$ cursor , $ ids ] = $ values ;
265
+
245
266
while ($ ids || '0 ' !== $ cursor ) {
246
267
$ this ->doDelete ($ ids );
247
268
@@ -264,7 +285,7 @@ protected function doInvalidate(array $tagIds): bool
264
285
}
265
286
}
266
287
267
- return true ;
288
+ return $ success ;
268
289
}
269
290
270
291
private function getRedisEvictionPolicy (): string
0 commit comments