goBloomFilter/lua.go
2025-04-15 14:27:26 +08:00

32 lines
576 B
Go

package bloomfilter
const LuaBloomBatchGetBits = `
local bloomKey = KEYS[1]
local bitsCnt = ARGV[1]
for i=1,bitsCnt,1 do
local offset = ARGV[i+1]
local result = redis.call('getbit',bloomKey,offset)
if (not result) then
error('FALL')
return 0
end
if (result == 0) then
return 0
end
end
return 1
`
const LuaBloomBatchSetBits = `
local bloomKey = KEYS[1]
local bitsCnt = ARGV[1]
for i=1,bitsCnt,1 do
local offset = ARGV[i+1]
local result = redis.call('setbit',bloomKey,offset,1)
if (not result) then
error('FALL')
return 0
end
end
`