Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- hmincrby for redis
- --
- -- Usage:
- -- redis-cli EVAL "$(cat hmincrby.lua)" 1 key field1 num1 field2 num2 ... fieldn numn
- if 1 ~= table.getn(KEYS) then
- error("Must have exactly 1 key")
- end
- if 0 ~= table.getn(ARGV) % 2 then
- error("Must have an even number of arguments")
- end
- local results = {}
- for i = 0, #ARGV / 2 - 1 do
- local f = ARGV[(i * 2) + 1]
- local n = ARGV[(i * 2) + 2]
- -- pcall captures the exception so the error will be in the returned array
- -- of results so the caller should be able to retry just the erroneous
- -- field/num pairs without any double counting
- table.insert(results, redis.pcall('HINCRBY', KEYS[1], f, n))
- end
- return results
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement