Skip to content

Commit

Permalink
Merge pull request #3387 from kdambekalns/task/use-scan-for-redis-flush
Browse files Browse the repository at this point in the history
TASK: Use `SCAN` for redis flush
  • Loading branch information
kdambekalns authored Nov 8, 2024
2 parents 87c6087 + 48381d2 commit 10cdecd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Neos.Cache/Classes/Backend/RedisBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,15 @@ public function flush(): void
{
// language=lua
$script = "
local keys = redis.call('KEYS', ARGV[1] .. '*')
for k1,key in ipairs(keys) do
redis.call('DEL', key)
end
local cursor = '0'
repeat
local result = redis.call('SCAN', cursor, 'MATCH', ARGV[1] .. '*')
cursor = result[1]
local keys = result[2]
for _, key in ipairs(keys) do
redis.call('DEL', key)
end
until cursor == '0'
";
$this->redis->eval($script, [$this->getPrefixedIdentifier('')], 0);

Expand Down

0 comments on commit 10cdecd

Please sign in to comment.