我在Redis环境中执行了以下Lua脚本:
local result = {}
local comment_ids = redis.call('smembers', 'comment:all')
for _, key in ipairs(comment_ids) do
local comment_text = ...
local article_name = ...
local user_name = ...
result[#result+1] = {article_name, user_name, comment_text}
end
return result
基本上,这里发生的是我们用一些聚合数据(article_name,user_name,comment_text)填充'result'表并返回它。
据我所知,这个表将完全存储在内存中,直到return语句。
我的主要问题是,我可以逐行返回数据,而不在内存中存储完整的响应吗?
而且,使用Lua脚本进行聚合是否合适? (就像我想在这里做的那样)。 感谢。
答案 0 :(得分:0)
不,您无法传输结果。
WRT the also - 这是非常合适的。