diff --git a/ContentGrabbingJi-CacheStore-redis/src/main/lua/RemoveKeysByPrefix.lua b/ContentGrabbingJi-CacheStore-redis/src/main/lua/RemoveKeysByPrefix.lua new file mode 100644 index 0000000..48c0a8e --- /dev/null +++ b/ContentGrabbingJi-CacheStore-redis/src/main/lua/RemoveKeysByPrefix.lua @@ -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