Skip to content

Commit e5b282b

Browse files
committed
fix flushing stale tags
1 parent 570c154 commit e5b282b

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/Illuminate/Cache/Console/PruneStaleTagsCommand.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,10 @@ public function handle(CacheManager $cache)
3535
{
3636
$cache = $cache->store($this->argument('store'));
3737

38-
if (! $cache->getStore() instanceof RedisStore) {
39-
$this->components->error('Pruning cache tags is only necessary when using Redis.');
40-
41-
return 1;
38+
if (method_exists($cache->getStore(), 'flushStaleTags')) {
39+
$cache->flushStaleTags();
4240
}
4341

44-
$cache->flushStaleTags();
45-
4642
$this->components->info('Stale cache tags pruned successfully.');
4743
}
4844

src/Illuminate/Cache/FailoverStore.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Illuminate\Cache;
44

55
use Illuminate\Cache\Events\CacheFailedOver;
6+
use Illuminate\Cache\RedisStore;
67
use Illuminate\Contracts\Cache\LockProvider;
78
use Illuminate\Contracts\Events\Dispatcher;
89
use RuntimeException;
@@ -162,6 +163,22 @@ public function flush()
162163
return $this->attemptOnAllStores(__FUNCTION__, func_get_args());
163164
}
164165

166+
/**
167+
* Remove all expired tag set entries.
168+
*
169+
* @return void
170+
*/
171+
public function flushStaleTags()
172+
{
173+
foreach ($this->stores as $store) {
174+
if ($this->store($store) instanceof RedisStore) {
175+
$this->store($store)->flushStaleTags();
176+
177+
break;
178+
}
179+
}
180+
}
181+
165182
/**
166183
* Get the cache key prefix.
167184
*

0 commit comments

Comments
 (0)