getDependencyCounts-4.lua 729 B

12345678910111213141516171819202122232425262728293031
  1. --[[
  2. Get counts per child states
  3. Input:
  4. KEYS[1] processed key
  5. KEYS[2] unprocessed key
  6. KEYS[3] ignored key
  7. KEYS[4] failed key
  8. ARGV[1...] types
  9. ]]
  10. local rcall = redis.call;
  11. local processedKey = KEYS[1]
  12. local unprocessedKey = KEYS[2]
  13. local ignoredKey = KEYS[3]
  14. local failedKey = KEYS[4]
  15. local results = {}
  16. for i = 1, #ARGV do
  17. if ARGV[i] == "processed" then
  18. results[#results+1] = rcall("HLEN", processedKey)
  19. elseif ARGV[i] == "unprocessed" then
  20. results[#results+1] = rcall("SCARD", unprocessedKey)
  21. elseif ARGV[i] == "ignored" then
  22. results[#results+1] = rcall("HLEN", ignoredKey)
  23. else
  24. results[#results+1] = rcall("ZCARD", failedKey)
  25. end
  26. end
  27. return results