Class: Alephant::Broker::Cache::NullClient

Inherits:
Object
  • Object
show all
Defined in:
lib/alephant/broker/cache/null_client.rb

Instance Method Summary collapse

Constructor Details

#initializeNullClient

Returns a new instance of NullClient.



5
6
7
# File 'lib/alephant/broker/cache/null_client.rb', line 5

def initialize
  @cache = {}
end

Instance Method Details

#get(key) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/alephant/broker/cache/null_client.rb', line 9

def get(key)
  data = @cache[key]

  return data if data

  set(key, yield) if block_given?
end

#set(key, value, _ttl = nil) ⇒ Object



17
18
19
# File 'lib/alephant/broker/cache/null_client.rb', line 17

def set(key, value, _ttl = nil)
  @cache[key] = value
end