blob: 5a00ae3fc408ce82f0f1881b95ad00c8ec7996f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
-- Lua script that checks if we can store a new training vector
-- Uses the following keys:
-- key1 - ann key
-- returns nspam,nham (or nil if locked)
local prefix = KEYS[1]
local locked = redis.call('HGET', prefix, 'lock')
if locked then
local host = redis.call('HGET', prefix, 'hostname') or 'unknown'
return string.format('%s:%s', host, locked)
end
local nspam = 0
local nham = 0
local ret = redis.call('SCARD', prefix .. '_spam_set')
if ret then nspam = tonumber(ret) end
ret = redis.call('SCARD', prefix .. '_ham_set')
if ret then nham = tonumber(ret) end
return {nspam,nham}
|