Skip to content

Commit 2c74a85

Browse files
authored
[12.x] Refactor RedisTaggedCache@flush() to allow for custom connections (#57122)
* Refactor flush method to improve redisPrefix retrieval Refactor redisPrefix assignment to use instance checks. * clean up
1 parent db46b79 commit 2c74a85

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Illuminate/Cache/RedisTaggedCache.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,11 @@ public function flush()
112112
{
113113
$this->event(new CacheFlushing($this->getName()));
114114

115-
$redisPrefix = match ($this->store->connection()::class) {
116-
PhpRedisConnection::class => $this->store->connection()->client()->getOption(\Redis::OPT_PREFIX),
117-
PredisConnection::class => $this->store->connection()->client()->getOptions()->prefix,
115+
$connection = $this->store->connection();
116+
117+
$redisPrefix = match (true) {
118+
$connection instanceof PhpRedisConnection => $connection->client()->getOption(\Redis::OPT_PREFIX),
119+
$connection instanceof PredisConnection => $connection->client()->getOptions()->prefix,
118120
};
119121

120122
$cachePrefix = $redisPrefix.$this->store->getPrefix();
@@ -143,16 +145,13 @@ public function flush()
143145
end
144146
LUA;
145147

146-
$this->store->connection()->eval(
148+
$connection->eval(
147149
$script,
148150
count($keysToBeDeleted),
149151
...$keysToBeDeleted,
150152
...[$cachePrefix, ...$cacheTags]
151153
);
152154

153-
// $this->flushValues();
154-
// $this->tags->flush();
155-
156155
$this->event(new CacheFlushed($this->getName()));
157156

158157
return true;

0 commit comments

Comments
 (0)