Sha256: 1cdfe1de6ebf428584cdbc5d9e3d4b0ef68a66313e0b6b5ad044631ee8e655f7

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

module ArAsyncCounterCache

  def self.resque_job_queue=(sym)
    ArAsyncCounterCache::IncrementCountersJob.class_eval do
      @queue = sym
    end
  end

  class IncrementCountersJob
    @queue = :default

    # Take advantage of resque-retry if possible.
    begin
      require 'resque-retry'
      require 'active_record/base'
      extend Resque::Plugins::ExponentialBackoff
      @retry_exceptions = [::ActiveRecord::RecordNotFound]
      @backoff_strategy = [0, 10, 100]
    rescue LoadError
    end

    def self.perform(klass_name, id)
      Object.const_get(klass_name).find(id).update_async_counters(:increment)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ar-async-counter-cache-0.0.2 lib/ar_async_counter_cache/increment_counters_job.rb