Class: Alephant::Broker::LoadStrategy::Revalidate::Refresher

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/alephant/broker/load_strategy/revalidate/refresher.rb

Constant Summary collapse

INFLIGHT_CACHE_TTL =

expire the inflight key after 2 minutes

120

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component_meta) ⇒ Refresher

Returns a new instance of Refresher.



12
13
14
# File 'lib/alephant/broker/load_strategy/revalidate/refresher.rb', line 12

def initialize(component_meta)
  @component_meta = component_meta
end

Instance Attribute Details

#component_metaObject (readonly)

Returns the value of attribute component_meta.



10
11
12
# File 'lib/alephant/broker/load_strategy/revalidate/refresher.rb', line 10

def component_meta
  @component_meta
end

Instance Method Details

#refreshObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/alephant/broker/load_strategy/revalidate/refresher.rb', line 16

def refresh
  inflight = cache.get(inflight_cache_key)

  logger.info(event: 'Inflight?', cache_val: inflight, method: "#{self.class}#refresh")

  return if inflight

  logger.info(event: 'QueueMessage', message: message, method: "#{self.class}#refresh")

  queue.send_message(message)
  cache.set(inflight_cache_key, true, INFLIGHT_CACHE_TTL)
end