Class: Upkeep::Subscriptions::ShapeCache
- Inherits:
-
Object
- Object
- Upkeep::Subscriptions::ShapeCache
- Defined in:
- lib/upkeep/subscriptions/shape.rb
Defined Under Namespace
Classes: Result, Shape, TemplateSubscription
Constant Summary collapse
- NOTIFICATION =
"subscription_shape.upkeep"
Instance Method Summary collapse
-
#initialize(index_builder: ReverseIndex.new) ⇒ ShapeCache
constructor
A new instance of ShapeCache.
- #reset ⇒ Object
- #resolve(recorder:, decision:, signature: nil) ⇒ Object
Constructor Details
#initialize(index_builder: ReverseIndex.new) ⇒ ShapeCache
Returns a new instance of ShapeCache.
16 17 18 19 20 |
# File 'lib/upkeep/subscriptions/shape.rb', line 16 def initialize(index_builder: ReverseIndex.new) @index_builder = index_builder @shapes = {} @mutex = Mutex.new end |
Instance Method Details
#reset ⇒ Object
43 44 45 |
# File 'lib/upkeep/subscriptions/shape.rb', line 43 def reset @mutex.synchronize { @shapes = {} } end |
#resolve(recorder:, decision:, signature: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/upkeep/subscriptions/shape.rb', line 22 def resolve(recorder:, decision:, signature: nil) if ActiveSupport::Notifications.notifier.listening?(NOTIFICATION) payload = {} ActiveSupport::Notifications.instrument(NOTIFICATION, payload) do result = resolve_without_instrumentation(recorder: recorder, decision: decision, signature: signature) payload.merge!( key: result.key, cache_state: result.cache_state, cacheable: result.cacheable, reason: result.reason, entries: result.entries.size, shared_stream_names: result.shared_stream_names.size ) payload.merge!(result.timings) result end else resolve_without_instrumentation(recorder: recorder, decision: decision, signature: signature) end end |