Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Lua script that can be embedded in Redis server for adding an element to a KMinHash set backed by a Redis sorted set
local count ='ZCARD', KEYS[1]);
if count == tonumber(ARGV[1]) then
local max_score ='ZRANGE', KEYS[1], -1, -1, 'WITHSCORES')[2]
if tonumber(ARGV[2]) >= tonumber(max_score) then
else'ZREMRANGEBYRANK', KEYS[1], -1, -1)
end'ZADD', KEYS[1], tonumber(ARGV[2]), tonumber(ARGV[3]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.