Method: Readthis::Cache#read

Defined in:
lib/readthis/cache.rb

#read(key, options = {}) ⇒ Object

Fetches data from the cache, using the given key. If there is data in the cache with the given key, then that data is returned. Otherwise, nil is returned.

Examples:


cache.read('missing') # => nil
cache.read('matched') # => 'some value'

Parameters:

  • key (String)

    Key for lookup

  • options (Hash) (defaults to: {})

    Optional overrides



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/readthis/cache.rb', line 78

def read(key, options = {})
  options = merged_options(options)

  invoke(:read, key) do |store|
    key = namespaced_key(key, options)

    refresh_entity(key, store, options)

    entity.load(store.get(key))
  end
end