1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00
dragonflydb-dragonfly/tests/dragonfly/seeder/script-hashlib.lua
Vladislav 75eaeb32db
feat(pytest): More types for seeder (#2577)
* feat(pytest): More types for seeder

Add more types to the seeder and refactor replication test

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
2024-02-20 15:31:08 +03:00

31 lines
917 B
Lua

local LH_funcs = {}
function LH_funcs.string(key, hash)
-- add value to hash
return dragonfly.ihash(hash, false, 'GET', key)
end
function LH_funcs.list(key, hash)
-- add values to hash
return dragonfly.ihash(hash, false, 'LRANGE', key, 0, -1)
end
function LH_funcs.set(key, hash)
-- add values to hash, sort before to avoid ambiguity
return dragonfly.ihash(hash, true, 'SMEMBERS', key)
end
function LH_funcs.zset(key, hash)
-- add values to hash, ZRANGE returns always sorted values
return dragonfly.ihash(hash, false, 'ZRANGE', key, 0, -1, 'WITHSCORES')
end
function LH_funcs.hash(key, hash)
-- add values to hash, first convert to key-value pairs and sort
return dragonfly.ihash(hash, true, 'HGETALL', key)
end
function LH_funcs.json(key, hash)
-- add values to hash, note JSON.GET returns just a string
return dragonfly.ihash(hash, false, 'JSON.GET', key)
end