sidekiq-unique-jobs 6.0.25 → 7.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq-unique-jobs might be problematic. Click here for more details.

Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +155 -20
  3. data/README.md +349 -112
  4. data/lib/sidekiq-unique-jobs.rb +2 -0
  5. data/lib/sidekiq_unique_jobs.rb +43 -6
  6. data/lib/sidekiq_unique_jobs/batch_delete.rb +121 -0
  7. data/lib/sidekiq_unique_jobs/changelog.rb +71 -0
  8. data/lib/sidekiq_unique_jobs/cli.rb +20 -29
  9. data/lib/sidekiq_unique_jobs/config.rb +193 -0
  10. data/lib/sidekiq_unique_jobs/connection.rb +5 -4
  11. data/lib/sidekiq_unique_jobs/constants.rb +36 -24
  12. data/lib/sidekiq_unique_jobs/core_ext.rb +38 -0
  13. data/lib/sidekiq_unique_jobs/digests.rb +78 -93
  14. data/lib/sidekiq_unique_jobs/exceptions.rb +152 -8
  15. data/lib/sidekiq_unique_jobs/job.rb +3 -3
  16. data/lib/sidekiq_unique_jobs/json.rb +34 -0
  17. data/lib/sidekiq_unique_jobs/key.rb +93 -0
  18. data/lib/sidekiq_unique_jobs/lock.rb +295 -0
  19. data/lib/sidekiq_unique_jobs/lock/base_lock.rb +49 -43
  20. data/lib/sidekiq_unique_jobs/lock/client_validator.rb +28 -0
  21. data/lib/sidekiq_unique_jobs/lock/server_validator.rb +27 -0
  22. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +8 -17
  23. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +5 -5
  24. data/lib/sidekiq_unique_jobs/lock/until_expired.rb +1 -23
  25. data/lib/sidekiq_unique_jobs/lock/validator.rb +65 -0
  26. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +12 -8
  27. data/lib/sidekiq_unique_jobs/lock/while_executing_reject.rb +1 -1
  28. data/lib/sidekiq_unique_jobs/lock_config.rb +95 -0
  29. data/lib/sidekiq_unique_jobs/lock_info.rb +68 -0
  30. data/lib/sidekiq_unique_jobs/locksmith.rb +255 -99
  31. data/lib/sidekiq_unique_jobs/logging.rb +148 -22
  32. data/lib/sidekiq_unique_jobs/logging/middleware_context.rb +44 -0
  33. data/lib/sidekiq_unique_jobs/lua/delete.lua +51 -0
  34. data/lib/sidekiq_unique_jobs/lua/delete_by_digest.lua +46 -0
  35. data/lib/sidekiq_unique_jobs/lua/delete_job_by_digest.lua +38 -0
  36. data/lib/sidekiq_unique_jobs/lua/find_digest_in_queues.lua +26 -0
  37. data/lib/sidekiq_unique_jobs/lua/find_digest_in_sorted_set.lua +24 -0
  38. data/lib/sidekiq_unique_jobs/lua/lock.lua +91 -0
  39. data/lib/sidekiq_unique_jobs/lua/locked.lua +35 -0
  40. data/lib/sidekiq_unique_jobs/lua/queue.lua +83 -0
  41. data/lib/sidekiq_unique_jobs/lua/reap_orphans.lua +86 -0
  42. data/lib/sidekiq_unique_jobs/lua/shared/_common.lua +40 -0
  43. data/lib/sidekiq_unique_jobs/lua/shared/_current_time.lua +8 -0
  44. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_queue.lua +19 -0
  45. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_sorted_set.lua +18 -0
  46. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua +46 -0
  47. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_sorted_set.lua +24 -0
  48. data/lib/sidekiq_unique_jobs/lua/shared/_hgetall.lua +13 -0
  49. data/lib/sidekiq_unique_jobs/lua/shared/_upgrades.lua +3 -0
  50. data/lib/sidekiq_unique_jobs/lua/shared/find_digest_in_sorted_set.lua +24 -0
  51. data/lib/sidekiq_unique_jobs/lua/unlock.lua +99 -0
  52. data/lib/sidekiq_unique_jobs/lua/update_version.lua +40 -0
  53. data/lib/sidekiq_unique_jobs/lua/upgrade.lua +68 -0
  54. data/lib/sidekiq_unique_jobs/middleware.rb +62 -31
  55. data/lib/sidekiq_unique_jobs/middleware/client.rb +42 -0
  56. data/lib/sidekiq_unique_jobs/middleware/server.rb +27 -0
  57. data/lib/sidekiq_unique_jobs/normalizer.rb +3 -3
  58. data/lib/sidekiq_unique_jobs/on_conflict.rb +22 -9
  59. data/lib/sidekiq_unique_jobs/on_conflict/log.rb +8 -4
  60. data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +59 -13
  61. data/lib/sidekiq_unique_jobs/on_conflict/replace.rb +42 -13
  62. data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +4 -4
  63. data/lib/sidekiq_unique_jobs/on_conflict/strategy.rb +24 -5
  64. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +47 -23
  65. data/lib/sidekiq_unique_jobs/orphans/manager.rb +100 -0
  66. data/lib/sidekiq_unique_jobs/orphans/observer.rb +42 -0
  67. data/lib/sidekiq_unique_jobs/orphans/reaper.rb +201 -0
  68. data/lib/sidekiq_unique_jobs/profiler.rb +51 -0
  69. data/lib/sidekiq_unique_jobs/redis.rb +11 -0
  70. data/lib/sidekiq_unique_jobs/redis/entity.rb +94 -0
  71. data/lib/sidekiq_unique_jobs/redis/hash.rb +56 -0
  72. data/lib/sidekiq_unique_jobs/redis/list.rb +32 -0
  73. data/lib/sidekiq_unique_jobs/redis/set.rb +32 -0
  74. data/lib/sidekiq_unique_jobs/redis/sorted_set.rb +59 -0
  75. data/lib/sidekiq_unique_jobs/redis/string.rb +49 -0
  76. data/lib/sidekiq_unique_jobs/rspec/matchers.rb +19 -0
  77. data/lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb +43 -0
  78. data/lib/sidekiq_unique_jobs/{scripts.rb → script.rb} +43 -29
  79. data/lib/sidekiq_unique_jobs/script/caller.rb +125 -0
  80. data/lib/sidekiq_unique_jobs/script/template.rb +41 -0
  81. data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +92 -65
  82. data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +166 -28
  83. data/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb +10 -11
  84. data/lib/sidekiq_unique_jobs/testing.rb +47 -15
  85. data/lib/sidekiq_unique_jobs/time_calculator.rb +103 -0
  86. data/lib/sidekiq_unique_jobs/timing.rb +58 -0
  87. data/lib/sidekiq_unique_jobs/unique_args.rb +19 -21
  88. data/lib/sidekiq_unique_jobs/unlockable.rb +11 -2
  89. data/lib/sidekiq_unique_jobs/update_version.rb +25 -0
  90. data/lib/sidekiq_unique_jobs/upgrade_locks.rb +151 -0
  91. data/lib/sidekiq_unique_jobs/version.rb +3 -1
  92. data/lib/sidekiq_unique_jobs/version_check.rb +1 -1
  93. data/lib/sidekiq_unique_jobs/web.rb +25 -19
  94. data/lib/sidekiq_unique_jobs/web/helpers.rb +98 -6
  95. data/lib/sidekiq_unique_jobs/web/views/lock.erb +108 -0
  96. data/lib/sidekiq_unique_jobs/web/views/locks.erb +52 -0
  97. data/lib/tasks/changelog.rake +4 -3
  98. metadata +70 -35
  99. data/lib/sidekiq_unique_jobs/client/middleware.rb +0 -56
  100. data/lib/sidekiq_unique_jobs/server/middleware.rb +0 -46
  101. data/lib/sidekiq_unique_jobs/timeout.rb +0 -8
  102. data/lib/sidekiq_unique_jobs/timeout/calculator.rb +0 -63
  103. data/lib/sidekiq_unique_jobs/util.rb +0 -103
  104. data/lib/sidekiq_unique_jobs/web/views/unique_digest.erb +0 -28
  105. data/lib/sidekiq_unique_jobs/web/views/unique_digests.erb +0 -46
  106. data/redis/acquire_lock.lua +0 -21
  107. data/redis/convert_legacy_lock.lua +0 -13
  108. data/redis/delete.lua +0 -14
  109. data/redis/delete_by_digest.lua +0 -23
  110. data/redis/delete_job_by_digest.lua +0 -60
  111. data/redis/lock.lua +0 -62
  112. data/redis/release_stale_locks.lua +0 -90
  113. data/redis/unlock.lua +0 -35
@@ -5,63 +5,189 @@ module SidekiqUniqueJobs
5
5
  #
6
6
  # @author Mikael Henriksson <mikael@zoolutions.se>
7
7
  module Logging
8
- # A convenience method for using the configured logger
8
+ def self.included(base)
9
+ base.send(:extend, self)
10
+ end
11
+
12
+ #
13
+ # A convenience method for using the configured gem logger
14
+ #
15
+ # @see SidekiqUniqueJobs#.logger
16
+ #
17
+ # @return [Logger]
18
+ #
9
19
  def logger
10
20
  SidekiqUniqueJobs.logger
11
21
  end
12
22
 
23
+ #
13
24
  # Logs a message at debug level
14
- # @param message_or_exception [String, Exception] the message or exception to log
15
- # @yield the message or exception to use for log message
16
- # Used for compatibility with logger
25
+ #
26
+ # @param [String, Exception] message_or_exception the message or exception to log
27
+ #
28
+ # @return [void]
29
+ #
30
+ # @yield [String, Exception] the message or exception to use for log message
31
+ #
17
32
  def log_debug(message_or_exception = nil, &block)
18
33
  logger.debug(message_or_exception, &block)
19
34
  nil
20
35
  end
21
36
 
37
+ #
22
38
  # Logs a message at info level
23
- # @param message_or_exception [String, Exception] the message or exception to log
24
- # @yield the message or exception to use for log message
25
- # Used for compatibility with logger
39
+ #
40
+ # @param [String, Exception] message_or_exception the message or exception to log
41
+ #
42
+ # @return [void]
43
+ #
44
+ # @yield [String, Exception] the message or exception to use for log message
45
+ #
26
46
  def log_info(message_or_exception = nil, &block)
27
47
  logger.info(message_or_exception, &block)
28
48
  nil
29
49
  end
30
50
 
51
+ #
31
52
  # Logs a message at warn level
32
- # @param message_or_exception [String, Exception] the message or exception to log
33
- # @yield the message or exception to use for log message
34
- # Used for compatibility with logger
53
+ #
54
+ # @param [String, Exception] message_or_exception the message or exception to log
55
+ #
56
+ # @return [void]
57
+ #
58
+ # @yield [String, Exception] the message or exception to use for log message
59
+ #
35
60
  def log_warn(message_or_exception = nil, &block)
36
61
  logger.warn(message_or_exception, &block)
37
62
  nil
38
63
  end
39
64
 
65
+ #
40
66
  # Logs a message at error level
41
- # @param message_or_exception [String, Exception] the message or exception to log
42
- # @yield the message or exception to use for log message
43
- # Used for compatibility with logger
67
+ #
68
+ # @param [String, Exception] message_or_exception the message or exception to log
69
+ #
70
+ # @return [void]
71
+ #
72
+ # @yield [String, Exception] the message or exception to use for log message
73
+ #
44
74
  def log_error(message_or_exception = nil, &block)
45
75
  logger.error(message_or_exception, &block)
46
76
  nil
47
77
  end
48
78
 
79
+ #
49
80
  # Logs a message at fatal level
50
- # @param message_or_exception [String, Exception] the message or exception to log
51
- # @yield the message or exception to use for log message
52
- # Used for compatibility with logger
81
+ #
82
+ # @param [String, Exception] message_or_exception the message or exception to log
83
+ #
84
+ # @return [void]
85
+ #
86
+ # @yield [String, Exception] the message or exception to use for log message
87
+ #
53
88
  def log_fatal(message_or_exception = nil, &block)
54
89
  logger.fatal(message_or_exception, &block)
55
90
  nil
56
91
  end
57
92
 
58
- def logging_context(middleware_class, job_hash)
59
- digest = job_hash["unique_digest"]
60
- if defined?(Sidekiq::Logging)
61
- "#{middleware_class} #{"DIG-#{digest}" if digest}"
62
- else
63
- { middleware: middleware_class, unique_digest: digest }
93
+ #
94
+ # Wraps the middleware logic with context aware logging
95
+ #
96
+ #
97
+ # @return [void]
98
+ #
99
+ # @yieldreturn [void] yield to the middleware instance
100
+ #
101
+ def with_logging_context
102
+ with_configured_loggers_context do
103
+ return yield
64
104
  end
105
+
106
+ nil # Need to make sure we don't return anything here
107
+ end
108
+
109
+ #
110
+ # Attempt to setup context aware logging for the given logger
111
+ #
112
+ #
113
+ # @return [void]
114
+ #
115
+ # @yield
116
+ #
117
+ def with_configured_loggers_context
118
+ logger_method.call(logging_context) { yield }
119
+ end
120
+
121
+ #
122
+ # Setup some variables to add to each log line
123
+ #
124
+ #
125
+ # @return [Hash] the context to use for each log line
126
+ #
127
+ def logging_context
128
+ raise NotImplementedError, "#{__method__} needs to be implemented in #{self.class}"
129
+ end
130
+
131
+ private
132
+
133
+ #
134
+ # A memoized method to use for setting up a logging context
135
+ #
136
+ #
137
+ # @return [proc] the method to call
138
+ #
139
+ def logger_method
140
+ @logger_method ||= sidekiq_context_method
141
+ @logger_method ||= sidekiq_logger_context_method
142
+ @logger_method ||= sidekiq_logging_context_method
143
+ @logger_method ||= no_sidekiq_context_method
144
+ end
145
+
146
+ #
147
+ # Checks if the logger respond to `with_context`.
148
+ #
149
+ # @note only used to remove the need for explicitly ignoring manual dispatch in other places.
150
+ #
151
+ #
152
+ # @return [true,false]
153
+ #
154
+ def logger_respond_to_with_context?
155
+ logger.respond_to?(:with_context)
156
+ end
157
+
158
+ #
159
+ # Checks if the logger context takes a hash argument
160
+ #
161
+ # @note only used to remove the need for explicitly ignoring manual dispatch in other places.
162
+ #
163
+ #
164
+ # @return [true,false]
165
+ #
166
+ def logger_context_hash?
167
+ defined?(Sidekiq::Context) || logger_respond_to_with_context?
168
+ end
169
+
170
+ def sidekiq_context_method
171
+ Sidekiq::Context.method(:with) if defined?(Sidekiq::Context)
172
+ end
173
+
174
+ def sidekiq_logger_context_method
175
+ logger.method(:with_context) if logger_respond_to_with_context?
176
+ end
177
+
178
+ def sidekiq_logging_context_method
179
+ Sidekiq::Logging.method(:with_context) if defined?(Sidekiq::Logging)
180
+ end
181
+
182
+ def no_sidekiq_context_method
183
+ method(:fake_logger_context)
184
+ end
185
+
186
+ def fake_logger_context(_context)
187
+ logger.warn "Don't know how to setup the logging context. Please open a feature request:" \
188
+ " https://github.com/mhenrixon/sidekiq-unique-jobs/issues/new?template=feature_request.md"
189
+
190
+ yield
65
191
  end
66
192
  end
67
193
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SidekiqUniqueJobs
4
+ #
5
+ # Provides the sidekiq middleware that makes the gem work
6
+ #
7
+ # @author Mikael Henriksson <mikael@zoolutions.se>
8
+ #
9
+ module Logging
10
+ #
11
+ # Context aware logging for Sidekiq Middlewares
12
+ #
13
+ # @author Mikael Henriksson <mikael@zoolutions.se>
14
+ #
15
+ module Middleware
16
+ include Logging
17
+
18
+ def self.included(base)
19
+ base.class_eval do
20
+ extend Logging::Middleware
21
+ end
22
+ end
23
+
24
+ #
25
+ # Provides a logging context for Sidekiq Middlewares
26
+ #
27
+ #
28
+ # @return [Hash] when logger responds to `:with_context`
29
+ # @return [String] when logger does not responds to `:with_context`
30
+ #
31
+ def logging_context
32
+ middleware = is_a?(SidekiqUniqueJobs::Middleware::Client) ? :client : :server
33
+ digest = item[UNIQUE_DIGEST]
34
+ lock_type = item[LOCK]
35
+
36
+ if logger_context_hash?
37
+ { "uniquejobs" => middleware, lock_type => digest }
38
+ else
39
+ "uniquejobs-#{middleware} #{"DIG-#{digest}" if digest}"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,51 @@
1
+ -------- BEGIN keys ---------
2
+ local digest = KEYS[1]
3
+ local queued = KEYS[2]
4
+ local primed = KEYS[3]
5
+ local locked = KEYS[4]
6
+ local info = KEYS[5]
7
+ local changelog = KEYS[6]
8
+ local digests = KEYS[7]
9
+ -------- END keys ---------
10
+
11
+ -------- BEGIN lock arguments ---------
12
+ local job_id = ARGV[1]
13
+ local pttl = tonumber(ARGV[2])
14
+ local lock_type = ARGV[3]
15
+ local limit = tonumber(ARGV[4])
16
+ -------- END lock arguments -----------
17
+
18
+ -------- BEGIN injected arguments --------
19
+ local current_time = tonumber(ARGV[5])
20
+ local debug_lua = tostring(ARGV[6]) == "true"
21
+ local max_history = tonumber(ARGV[7])
22
+ local script_name = tostring(ARGV[8]) .. ".lua"
23
+ local redisversion = tostring(ARGV[9])
24
+ --------- END injected arguments ---------
25
+
26
+ -------- BEGIN local functions --------
27
+ <%= include_partial "shared/_common.lua" %>
28
+ ---------- END local functions ----------
29
+
30
+
31
+ -------- BEGIN delete.lua --------
32
+ log_debug("BEGIN delete", digest)
33
+
34
+ local redis_version = toversion(redisversion)
35
+ local count = 0
36
+ local del_cmd = "DEL"
37
+
38
+ log_debug("ZREM", digests, digest)
39
+ count = count + redis.call("ZREM", digests, digest)
40
+
41
+ if redis_version["major"] >= 4 then del_cmd = "UNLINK"; end
42
+
43
+ log_debug(del_cmd, digest, queued, primed, locked, info)
44
+ count = count + redis.call(del_cmd, digest, queued, primed, locked, info)
45
+
46
+
47
+ log("Deleted (" .. count .. ") keys")
48
+ log_debug("END delete (" .. count .. ") keys for:", digest)
49
+
50
+ return count
51
+ -------- END delete.lua --------
@@ -0,0 +1,46 @@
1
+ -------- BEGIN keys ---------
2
+ local digest = KEYS[1]
3
+ local digests = KEYS[2]
4
+ -------- END keys ---------
5
+
6
+ -------- BEGIN injected arguments --------
7
+ local current_time = tonumber(ARGV[1])
8
+ local debug_lua = ARGV[2] == "true"
9
+ local max_history = tonumber(ARGV[3])
10
+ local script_name = tostring(ARGV[4]) .. ".lua"
11
+ local redisversion = tostring(ARGV[5])
12
+ --------- END injected arguments ---------
13
+
14
+ -------- BEGIN local functions --------
15
+ <%= include_partial "shared/_common.lua" %>
16
+ ---------- END local functions ----------
17
+
18
+ -------- BEGIN Variables --------
19
+ local queued = digest .. ":QUEUED"
20
+ local primed = digest .. ":PRIMED"
21
+ local locked = digest .. ":LOCKED"
22
+ local run_digest = digest .. ":RUN"
23
+ local run_queued = digest .. ":RUN:QUEUED"
24
+ local run_primed = digest .. ":RUN:PRIMED"
25
+ local run_locked = digest .. ":RUN:LOCKED"
26
+ -------- END Variables --------
27
+
28
+
29
+ -------- BEGIN delete_by_digest.lua --------
30
+ local counter = 0
31
+ local redis_version = toversion(redisversion)
32
+ local del_cmd = "DEL"
33
+
34
+ log_debug("BEGIN delete_by_digest:", digest)
35
+
36
+ if redis_version["major"] >= 4 then del_cmd = "UNLINK"; end
37
+
38
+ log_debug(del_cmd, digest, queued, primed, locked, run_digest, run_queued, run_primed, run_locked)
39
+ counter = redis.call(del_cmd, digest, queued, primed, locked, run_digest, run_queued, run_primed, run_locked)
40
+
41
+ log_debug("ZREM", digests, digest)
42
+ redis.call("ZREM", digests, digest)
43
+
44
+ log_debug("END delete_by_digest:", digest, "(deleted " .. counter .. " keys)")
45
+ return counter
46
+ -------- END delete_by_digest.lua --------
@@ -0,0 +1,38 @@
1
+ -------- BEGIN keys ---------
2
+ local queue = KEYS[1]
3
+ local schedule_set = KEYS[2]
4
+ local retry_set = KEYS[3]
5
+ -------- END keys ---------
6
+
7
+ -------- BEGIN Arguments ---------
8
+ local digest = ARGV[1]
9
+ -------- END Arguments ---------
10
+
11
+ -------- BEGIN injected arguments --------
12
+ local current_time = tonumber(ARGV[2])
13
+ local debug_lua = ARGV[3] == "true"
14
+ local max_history = tonumber(ARGV[4])
15
+ local script_name = tostring(ARGV[5]) .. ".lua"
16
+ --------- END injected arguments ---------
17
+
18
+ -------- BEGIN local functions --------
19
+ <%= include_partial "shared/_common.lua" %>
20
+ <%= include_partial "shared/_delete_from_queue.lua" %>
21
+ <%= include_partial "shared/_delete_from_sorted_set.lua" %>
22
+ ---------- END local functions ----------
23
+
24
+
25
+ -------- BEGIN delete_job_by_digest.lua --------
26
+ local result = delete_from_queue(queue, digest)
27
+ if result then
28
+ return result
29
+ end
30
+
31
+ result = delete_from_sorted_set(schedule_set, digest)
32
+ if result then
33
+ return result
34
+ end
35
+
36
+ result = delete_from_sorted_set(retry_set, digest)
37
+ return result
38
+ -------- END delete_job_by_digest.lua --------
@@ -0,0 +1,26 @@
1
+ -------- BEGIN keys ---------
2
+ local digest = KEYS[1]
3
+ -------- END keys ---------
4
+
5
+ -------- BEGIN injected arguments --------
6
+ local current_time = tonumber(ARGV[2])
7
+ local debug_lua = ARGV[3] == "true"
8
+ local max_history = tonumber(ARGV[4])
9
+ local script_name = tostring(ARGV[5]) .. ".lua"
10
+ --------- END injected arguments ---------
11
+
12
+
13
+ -------- BEGIN local functions --------
14
+ <%= include_partial "shared/_common.lua" %>
15
+ <%= include_partial "shared/_find_digest_in_queues.lua" %>
16
+ ---------- END local functions ----------
17
+
18
+
19
+ -------- BEGIN delete_orphaned.lua --------
20
+ log_debug("BEGIN")
21
+ local result = find_digest_in_queues(digest)
22
+ log_debug("END")
23
+ if result and result ~= nil then
24
+ return result
25
+ end
26
+ -------- END delete_orphaned.lua --------
@@ -0,0 +1,24 @@
1
+ local function find_digest_in_sorted_set(name, digest)
2
+ local cursor = 0
3
+ local count = 5
4
+ local pattern = "*" .. digest .. "*"
5
+ local found = false
6
+
7
+ log_debug("searching in:", name,
8
+ "for digest:", digest,
9
+ "cursor:", cursor)
10
+ repeat
11
+ local pagination = redis.call("ZSCAN", name, cursor, "MATCH", pattern, "COUNT", count)
12
+ local next_cursor = pagination[1]
13
+ local items = pagination[2]
14
+
15
+ if #items > 0 then
16
+ log_debug("Found digest", digest, "in zset:", name)
17
+ found = true
18
+ end
19
+
20
+ cursor = next_cursor
21
+ until found == true or cursor == "0"
22
+
23
+ return found
24
+ end