25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-10-31 15:21:38 +01:00
xmpp.chapril.org-ejabberd/priv/lua/redis_sm.lua
2018-07-14 17:53:00 +03:00

17 lines
557 B
Lua

redis.replicate_commands()
local cursor = redis.call('GET', KEYS[3]) or 0
local scan_result = redis.call('HSCAN', KEYS[1], cursor, 'COUNT', ARGV[1])
local newcursor = scan_result[1]
local cursor = redis.call('SET', KEYS[3], newcursor)
redis.call('EXPIRE', KEYS[3], 30)
for key,value in ipairs(scan_result[2]) do
local uskey, sidkey = string.match(value, '(.*)||(.*)')
if uskey and sidkey then
redis.call('HDEL', uskey, sidkey)
redis.call('HDEL', KEYS[1], value)
else
redis.call('HDEL', KEYS[2], value)
end
end
return newcursor