【发布时间】:2014-03-19 20:45:40
【问题描述】:
我想在 lua 中有一个简单的数据结构,类似于 Java HashMap 等价物。
这样做的目的是我希望维护一个唯一键“userID”,该键映射到一组不断更新的两个值,例如;
'77777', {254, 24992}
关于如何实现这一点的任何建议?
-- Individual Aggregations
local dictionary = ?
-- Other Vars
local sumCount = 0
local sumSize = 0
local matches = redis.call(KEYS, query)
for _,key in ipairs(matches) do
local val = redis.call(GET, key)
local count, size = val:match(([^:]+):([^:]+))
topUsers(string.sub(key, 11, 15), sumCount, sumSize)
-- Global Count and Size for the Query
sumCount = sumCount + tonumber(count)
sumSize = sumSize + tonumber(size)
end
local result = string.format(%s:%s, sumCount, sumSize)
return result;
-- Users Total Data Aggregations
function topUsers()
-- Do sums for each user
end
【问题讨论】:
标签: data-structures dictionary lua redis hashmap