Class: Faulty::Cache::AutoWire
- Inherits:
-
Object
- Object
- Faulty::Cache::AutoWire
- Defined in:
- lib/faulty/cache/auto_wire.rb
Overview
Automatically configure a cache backend
Used by Faulty#initialize to setup sensible cache defaults
Defined Under Namespace
Classes: Options
Class Method Summary collapse
-
.wrap(cache, **options) {|Options| ... } ⇒ Object
Wrap a cache backend with sensible defaults.
Class Method Details
.wrap(cache, **options) {|Options| ... } ⇒ Object
Wrap a cache backend with sensible defaults
If the cache is nil
, create a new Default.
If the backend is not fault tolerant, wrap it in CircuitProxy and FaultTolerantProxy.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/faulty/cache/auto_wire.rb', line 40 def wrap(cache, **, &block) = Options.new(, &block) if cache.nil? Cache::Default.new elsif cache.fault_tolerant? cache else Cache::FaultTolerantProxy.new( Cache::CircuitProxy.new(cache, circuit: .circuit, notifier: .notifier), notifier: .notifier ) end end |