mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
5b546df94d
Background We tried to be compatible with Valkey in their support of Lua flags, but we generally failed: We are not really compatible with Valkey because our flags are different (we reject unknown flags, and Valkey flags are unknown to us) The #!lua syntax doesn't work with Lua (# is not a comment), so scripts written for older versions of Redis can't be used with Dragonfly (i.e. they can't add Dragonfly flags and remain compatible with older Redis versions) Changes Instead of the previous syntax: #!lua flags=allow-undeclared-keys,disable-atomicity We now use this syntax: --!df flags=allow-undeclared-keys,disable-atomicity It is not backwards compatible (with older versions of Dragonfly), but it should be very easy to adapt to, and doesn't suffer from the disadvantages above. Related to #3512
29 lines
635 B
Lua
29 lines
635 B
Lua
--!df flags=disable-atomicity
|
|
--[[
|
|
Script for quickly computing single 64bit hash for keys of types specified in ARGV[].
|
|
Keys of every type are sorted lexicographically to ensure consistent order.
|
|
]]--
|
|
|
|
-- import:hashlib --
|
|
-- import:utillib --
|
|
|
|
-- inputs
|
|
local type = ARGV[1]
|
|
|
|
local OUT_HASH = 0
|
|
|
|
local function process(type)
|
|
local keys = LU_collect_keys('', type)
|
|
local hfunc = LH_funcs[type]
|
|
|
|
-- sort to provide consistent order
|
|
table.sort(keys)
|
|
for _, key in ipairs(keys) do
|
|
-- hand hash over to callback
|
|
OUT_HASH = hfunc(key, OUT_HASH)
|
|
end
|
|
end
|
|
|
|
process(string.lower(type))
|
|
|
|
return OUT_HASH
|