[Add] CacheStore-Redis 添加指定前缀键名删除脚本, 以提供带有原子性的 RedisCacheStore.clear 操作;

[Add] RemoveKeysByPrefix.lua 添加用于实现 RedisCacheStore.clear 操作的脚本;
This commit is contained in:
LamGC 2021-01-16 01:43:00 +08:00
parent c956c1b3d2
commit f414802c63
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D

View File

@ -0,0 +1,18 @@
local keyPrefix = tostring(KEYS[1])
if (keyPrefix == nil) then
return false
end
if (string.sub(keyPrefix, string.len(keyPrefix)) ~= "*") then
keyPrefix = keyPrefix .. "*"
end
local keys = redis.call("KEYS", keyPrefix)
local count = 0;
for _, v in ipairs(keys) do
count = count + redis.call("DEL", v)
end
return count