class Sidekiq::TransactionAwareClient

Public Class Methods

new(redis_pool) click to toggle source
# File lib/sidekiq/transaction_aware_client.rb, line 8
def initialize(redis_pool)
  @redis_client = Client.new(redis_pool)
end

Public Instance Methods

push(item) click to toggle source
# File lib/sidekiq/transaction_aware_client.rb, line 12
def push(item)
  # pre-allocate the JID so we can return it immediately and
  # save it to the database as part of the transaction.
  item["jid"] ||= SecureRandom.hex(12)
  AfterCommitEverywhere.after_commit { @redis_client.push(item) }
  item["jid"]
end
push_bulk(items) click to toggle source

We don't provide transactionality for push_bulk because we don't want to hold potentially hundreds of thousands of job records in memory due to a long running enqueue process.

# File lib/sidekiq/transaction_aware_client.rb, line 24
def push_bulk(items)
  @redis_client.push_bulk(items)
end