1
0
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:
2023-11-03 15:46:45 +08:00
parent 2f2af226ee
commit 01f426c5b2
6 changed files with 57 additions and 42 deletions

20
bloom/bloom.lua Normal file
View 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)