Sha256: ec2d696ecfc4f0dd4da60980b58ae2b03bf276fe3f8968e44c715bba214e5d20

Contents?: true

Size: 424 Bytes

Versions: 1

Compression:

Stored size: 424 Bytes

Contents

# frozen_string_literal: true
class Condenser::CacheStore

  def fetch(key)
    value = get(key)
    
    if value.nil?
      value = yield
      set(key, Marshal.dump(value))
    else
      value = Marshal.load(value)
    end
    value
  end
  
  
  def delete(key)
    @key_access.delete(key)
    if value = @cache.delete(key)
      @cache_size -= cached_size(key, value)
      true
    else
      false
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
condenser-0.0.4 lib/condenser/cache_store.rb