Module: SolidCache::Store::Failsafe

Included in:
SolidCache::Store
Defined in:
lib/solid_cache/store/failsafe.rb

Constant Summary collapse

TRANSIENT_ACTIVE_RECORD_ERRORS =
[
  ActiveRecord::AdapterTimeout,
  ActiveRecord::ConnectionNotEstablished,
  ActiveRecord::ConnectionTimeoutError,
  ActiveRecord::Deadlocked,
  ActiveRecord::LockWaitTimeout,
  ActiveRecord::QueryCanceled,
  ActiveRecord::StatementTimeout
]
DEFAULT_ERROR_HANDLER =
->(method:, returning:, exception:) do
  if Store.logger
    Store.logger.error { "SolidCacheStore: #{method} failed, returned #{returning.inspect}: #{exception.class}: #{exception.message}" }
  end
end

Instance Method Summary collapse

Instance Method Details

#initialize(options = {}) ⇒ Object



22
23
24
25
26
# File 'lib/solid_cache/store/failsafe.rb', line 22

def initialize(options = {})
  super(options)

  @error_handler = options.fetch(:error_handler, DEFAULT_ERROR_HANDLER)
end