Class: FCC::Station::Cache
- Inherits:
-
Object
- Object
- FCC::Station::Cache
- Defined in:
- lib/fcc/station/cache.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #fetch(key) ⇒ Object
- #flush ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
11 12 13 14 15 |
# File 'lib/fcc/station/cache.rb', line 11 def initialize @lightly = Lightly.new(life: '3d', hash: true).tap do |cache| cache.prune end end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
9 10 11 |
# File 'lib/fcc/station/cache.rb', line 9 def store @store end |
Instance Method Details
#fetch(key) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fcc/station/cache.rb', line 21 def fetch(key) FCC.log("Retreiving #{key} from cache") @lightly.get(key.to_s) do FCC.log "Loading up the cache with results for key: #{key}. This might take a minuteā¦" value = yield if value value else nil end end end |
#flush ⇒ Object
17 18 19 |
# File 'lib/fcc/station/cache.rb', line 17 def flush @lightly.flush end |