File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 33namespace Illuminate \Cache ;
44
55use Illuminate \Cache \Events \CacheFailedOver ;
6+ use Illuminate \Cache \RedisStore ;
67use Illuminate \Contracts \Cache \LockProvider ;
78use Illuminate \Contracts \Events \Dispatcher ;
89use 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 *
You can’t perform that action at this time.
0 commit comments