Skip to content

Instantly share code, notes, and snippets.

@brunomichetti
Created August 27, 2019 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunomichetti/800bdc372a7539809ab59ac97777e30e to your computer and use it in GitHub Desktop.
Save brunomichetti/800bdc372a7539809ab59ac97777e30e to your computer and use it in GitHub Desktop.
class CCDeferredEnqueuer < CCEnqueuer
def perform
@options[:source_object_class_name] = @base_class.constantize
counter_class = @options[:counter].constantize
counter = counter_class.new(nil, @options)
counter.save!
unmark_as_queued
Rails.logger.info { 'Updated counters from cache.' }
end
private
def enqueuer_name
'deferred'
end
def form_key
class_name = @options[:relation_class_name]
column_name = @options[:column]
instance_id = @options[:relation_id]
"cc::#{class_name}::#{instance_id}::#{column_name}::deferred"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment