mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
use redis function(Version 7 and above is required
)
This commit is contained in:
20
bloom/bloom.lua
Normal file
20
bloom/bloom.lua
Normal file
@ -0,0 +1,20 @@
|
||||
#!lua name=charlie_bloom
|
||||
|
||||
|
||||
local function set_bit(keys, args)
|
||||
for _, offset in ipairs(args) do
|
||||
redis.call("setbit", keys[1], offset, 1)
|
||||
end
|
||||
end
|
||||
|
||||
local function test_bit(keys, args)
|
||||
for _, offset in ipairs(args) do
|
||||
if tonumber(redis.call("getbit", keys[1], offset)) == 0 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
redis.register_function('set_bit',set_bit)
|
||||
redis.register_function('test_bit',test_bit)
|
Reference in New Issue
Block a user