Class: Alephant::Broker::Cache::NullClient
- Inherits:
-
Object
- Object
- Alephant::Broker::Cache::NullClient
- Defined in:
- lib/alephant/broker/cache/null_client.rb
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize ⇒ NullClient
constructor
A new instance of NullClient.
- #set(key, value, _ttl = nil) ⇒ Object
Constructor Details
#initialize ⇒ NullClient
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 |