Sha256: bb3b393cf970f05b3041cd93557a0d935b97da2c44214d8c153afaa716437449

Contents?: true

Size: 338 Bytes

Versions: 2

Compression:

Stored size: 338 Bytes

Contents

require "cachew/version"
require "cachew/adapters"

# Unified cache interface
class Cachew
  extend Forwardable

  attr_reader :adapter

  def initialize(store = nil)
    @adapter = Adapters.build_adapter_for store
  end

  def fetch(key)
    has?(key) ? get(key) : set(key, yield)
  end

  def_delegators :adapter, :set, :get, :has?
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cachew-0.1.1 lib/cachew.rb
cachew-0.1.0 lib/cachew.rb