Class: EntityCache::Store::External::Substitute::External
- Inherits:
-
Object
- Object
- EntityCache::Store::External::Substitute::External
- Includes:
- EntityCache::Store::External
- Defined in:
- lib/entity_cache/store/external/substitute.rb
Constant Summary
Constants included from EntityCache::Store::External
Instance Attribute Summary collapse
-
#telemetry_sink ⇒ Object
Returns the value of attribute telemetry_sink.
Class Method Summary collapse
Instance Method Summary collapse
- #add(id, entity, version, time) ⇒ Object
- #configure(session: nil) ⇒ Object
- #get(id) ⇒ Object
- #get_records ⇒ Object
- #put ⇒ Object
- #put?(&block) ⇒ Boolean
Methods included from EntityCache::Store::External
Instance Attribute Details
#telemetry_sink ⇒ Object
Returns the value of attribute telemetry_sink.
12 13 14 |
# File 'lib/entity_cache/store/external/substitute.rb', line 12 def telemetry_sink @telemetry_sink end |
Class Method Details
.build ⇒ Object
14 15 16 17 18 |
# File 'lib/entity_cache/store/external/substitute.rb', line 14 def self.build instance = new(subject) instance.configure instance end |
.subject ⇒ Object
57 58 59 |
# File 'lib/entity_cache/store/external/substitute.rb', line 57 def self.subject :substitute end |
Instance Method Details
#add(id, entity, version, time) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/entity_cache/store/external/substitute.rb', line 36 def add(id, entity, version, time) record = Record.new(id, entity, version, time) get_records[id] = record record end |
#configure(session: nil) ⇒ Object
20 21 22 |
# File 'lib/entity_cache/store/external/substitute.rb', line 20 def configure(session: nil) self.telemetry_sink = self.class.register_telemetry_sink(self) end |
#get(id) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/entity_cache/store/external/substitute.rb', line 24 def get(id) record = get_records[id] if record return record.entity, record.version, record.time end end |
#get_records ⇒ Object
32 33 34 |
# File 'lib/entity_cache/store/external/substitute.rb', line 32 def get_records @get_records ||= {} end |
#put ⇒ Object
44 45 |
# File 'lib/entity_cache/store/external/substitute.rb', line 44 def put(*) end |
#put?(&block) ⇒ Boolean
47 48 49 50 51 52 53 54 55 |
# File 'lib/entity_cache/store/external/substitute.rb', line 47 def put?(&block) block ||= proc { true } telemetry_sink.recorded_put? do |record| data = record.data block.(data.id, data.entity, data.version, data.time) end end |