Class: SolidObserver::Services::FlushCacheEventBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/solid_observer/services/flush_cache_event_buffer.rb

Constant Summary collapse

BATCH_SIZE =
100

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ FlushCacheEventBuffer

Returns a new instance of FlushCacheEventBuffer.



12
13
14
# File 'lib/solid_observer/services/flush_cache_event_buffer.rb', line 12

def initialize(events)
  @events = events
end

Class Method Details

.call(events) ⇒ Object



8
9
10
# File 'lib/solid_observer/services/flush_cache_event_buffer.rb', line 8

def self.call(events)
  new(events).call
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
# File 'lib/solid_observer/services/flush_cache_event_buffer.rb', line 16

def call
  return 0 if @events.empty?

  insert_all_events
  @events.size
rescue ActiveRecord::RecordInvalid, ActiveRecord::StatementInvalid => error
  fallback_insert_count(error)
end