mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-29 14:17:33 +00:00
[Add] CacheStore-Redis 添加指定前缀键名删除脚本, 以提供带有原子性的 RedisCacheStore.clear 操作;
[Add] RemoveKeysByPrefix.lua 添加用于实现 RedisCacheStore.clear 操作的脚本;
This commit is contained in:
parent
c956c1b3d2
commit
f414802c63
@ -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
|
Loading…
Reference in New Issue
Block a user