Sha256: e2feb329c4dbcfc950788193cb0db6494e089241f34639af3f486e020500402c

Contents?: true

Size: 385 Bytes

Versions: 1

Compression:

Stored size: 385 Bytes

Contents

module FastCache::Evaluator

  attr_accessor :evaluation_cache
  attr_accessor :default_expiration

  def cache_eval(key = "", expiration = @default_expiration)
    maybe = @evaluation_cache.get(key)
    if maybe.anything?
      Marshal.load(maybe.value)
    else
      value = yield
      @evaluation_cache.set(key, Marshal.dump(value), expiration || 0)
      value
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
binary42-fastcache-0.3 lib/fastcache/interface/evaluator.rb