class Sidekiq::TransactionAwareClient
Public Class Methods
Source
# File lib/sidekiq/transaction_aware_client.rb, line 8 def initialize(pool: nil, config: nil) @redis_client = Client.new(pool: pool, config: config) end
Public Instance Methods
Source
# File lib/sidekiq/transaction_aware_client.rb, line 12 def batching? Thread.current[:sidekiq_batch] end
Source
# File lib/sidekiq/transaction_aware_client.rb, line 16 def push(item) # 6160 we can't support both Sidekiq::Batch and transactions. return @redis_client.push(item) if batching? # 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
Source
# File lib/sidekiq/transaction_aware_client.rb, line 31 def push_bulk(items) @redis_client.push_bulk(items) end
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.