getCounts-1.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getCounts = void 0;
  4. const content = `--[[
  5. Get counts per provided states
  6. Input:
  7. KEYS[1] 'prefix'
  8. ARGV[1...] types
  9. ]]
  10. local rcall = redis.call;
  11. local prefix = KEYS[1]
  12. local results = {}
  13. for i = 1, #ARGV do
  14. local stateKey = prefix .. ARGV[i]
  15. if ARGV[i] == "wait" or ARGV[i] == "paused" then
  16. -- Markers in waitlist DEPRECATED in v5: Remove in v6.
  17. local marker = rcall("LINDEX", stateKey, -1)
  18. if marker and string.sub(marker, 1, 2) == "0:" then
  19. local count = rcall("LLEN", stateKey)
  20. if count > 1 then
  21. rcall("RPOP", stateKey)
  22. results[#results+1] = count-1
  23. else
  24. results[#results+1] = 0
  25. end
  26. else
  27. results[#results+1] = rcall("LLEN", stateKey)
  28. end
  29. elseif ARGV[i] == "active" then
  30. results[#results+1] = rcall("LLEN", stateKey)
  31. else
  32. results[#results+1] = rcall("ZCARD", stateKey)
  33. end
  34. end
  35. return results
  36. `;
  37. exports.getCounts = {
  38. name: 'getCounts',
  39. content,
  40. keys: 1,
  41. };
  42. //# sourceMappingURL=getCounts-1.js.map