Class: CounterOperationWorker
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- CounterOperationWorker
- Defined in:
- app/workers/counter_operation_worker.rb
Overview
Worker responsible for performing delayed operations on Counter records to maintain cache consistency and prevent race conditions when updating counter caches asynchronously.
Instance Method Summary collapse
-
#perform(operation, counter_id, value = nil) ⇒ Object
Process counter operations (create, update, or destroy) counter_id is the ID of the counter to operate on, or can be a `key` if operation is 'create'.
Methods inherited from ApplicationWorker
Instance Method Details
#perform(operation, counter_id, value = nil) ⇒ Object
Process counter operations (create, update, or destroy) counter_id is the ID of the counter to operate on, or can be a `key` if operation is 'create'.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/workers/counter_operation_worker.rb', line 13 def perform(operation, counter_id, value = nil) case operation when 'update' update_counter(counter_id, value) when 'destroy' destroy_counter(counter_id) when 'create' create_counter(counter_id, value) else APMErrorHandler.report('Unknown counter operation', { operation: operation, counter_id: counter_id, }) end end |