25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00
xmpp.chapril.org-ejabberd/priv/lua/redis_sm.lua

17 lines
557 B
Lua
Raw Normal View History

2018-07-14 16:53:00 +02:00
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