class FCC::Station::Cache

Attributes

store[R]

Public Class Methods

new() click to toggle source
# File lib/fcc/station/cache.rb, line 11
def initialize
  @lightly = Lightly.new(life: '3d', hash: true).tap do |cache|
    cache.prune
  end
end

Public Instance Methods

fetch(key) { || ... } click to toggle source
# 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() click to toggle source
# File lib/fcc/station/cache.rb, line 17
def flush
  @lightly.flush
end