r = redis.Redis()
lua = """
-- hgetall转字典
local function hgetallTolist(hlist)
local resultdict = {}
for i = 1, #hlist, 2 do
local result = {}
table.insert(resultdict, hlist[i]..hlist[i + 1])
end
return resultdict
end
local redis_list = ARGV
local redis_string = KEYS[1]
return allkeys
"""
lua_script = redis_2third_db.register_script(lua)
r.set('foo', 2)
data = lua_script(keys=['foo'], args=[5])
注意点:
1、local方法function写在上面
2、变量都要local