Class: JSONFactory::Cache

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/json_factory/cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCache

Returns a new instance of Cache.



8
9
10
# File 'lib/json_factory/cache.rb', line 8

def initialize
  @prefix = 'json_factory'
end

Instance Attribute Details

#prefixObject

Returns the value of attribute prefix.



6
7
8
# File 'lib/json_factory/cache.rb', line 6

def prefix
  @prefix
end

#storeObject

Returns the value of attribute store.



6
7
8
# File 'lib/json_factory/cache.rb', line 6

def store
  @store
end

Instance Method Details

#fetch(key, options = nil, &block) ⇒ Object



16
17
18
# File 'lib/json_factory/cache.rb', line 16

def fetch(key, options = nil, &block)
  store.fetch(transform_key(key), options, &block)
end

#transform_key(key) ⇒ Object



12
13
14
# File 'lib/json_factory/cache.rb', line 12

def transform_key(key)
  [prefix, key].compact.join(':')
end