Class: SidekiqUniqueJobs::BatchDelete
- Inherits:
-
Object
- Object
- SidekiqUniqueJobs::BatchDelete
- Includes:
- Connection, Logging
- Defined in:
- lib/sidekiq_unique_jobs/batch_delete.rb
Overview
Class BatchDelete provides batch deletion of digests
Constant Summary collapse
- BATCH_SIZE =
Returns the default batch size.
100
- SUFFIXES =
Returns Supported key suffixes.
%w[ QUEUED PRIMED LOCKED INFO ].freeze
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#digests ⇒ Object
readonly
Returns the value of attribute digests.
Class Method Summary collapse
-
.call(digests, conn = nil) ⇒ void
Executes a batch deletion of the provided digests.
Instance Method Summary collapse
-
#call ⇒ Object
Executes a batch deletion of the provided digests.
-
#initialize(digests, conn) ⇒ BatchDelete
constructor
Initialize a new batch delete instance.
Methods included from Logging
#build_message, included, #log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger, #logging_context, #with_configured_loggers_context, #with_logging_context
Methods included from Connection
Constructor Details
#initialize(digests, conn) ⇒ BatchDelete
Initialize a new batch delete instance
57 58 59 60 61 62 63 64 |
# File 'lib/sidekiq_unique_jobs/batch_delete.rb', line 57 def initialize(digests, conn) @count = 0 @digests = digests @conn = conn @digests ||= [] @digests.compact! redis_version # Avoid pipelined calling redis_version and getting a future. end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
37 38 39 |
# File 'lib/sidekiq_unique_jobs/batch_delete.rb', line 37 def conn @conn end |
#digests ⇒ Object (readonly)
Returns the value of attribute digests.
33 34 35 |
# File 'lib/sidekiq_unique_jobs/batch_delete.rb', line 33 def digests @digests end |
Class Method Details
.call(digests, conn = nil) ⇒ void
This method returns an undefined value.
Executes a batch deletion of the provided digests
47 48 49 |
# File 'lib/sidekiq_unique_jobs/batch_delete.rb', line 47 def self.call(digests, conn = nil) new(digests, conn).call end |
Instance Method Details
#call ⇒ Object
Just wraps batch_delete to be able to provide no connection
Executes a batch deletion of the provided digests
71 72 73 74 75 76 77 78 |
# File 'lib/sidekiq_unique_jobs/batch_delete.rb', line 71 def call return log_info("Nothing to delete; exiting.") if digests.none? log_info("Deleting batch with #{digests.size} digests") return batch_delete(conn) if conn redis { |rcon| batch_delete(rcon) } end |