Class: Cachew

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cachew.rb,
lib/cachew/version.rb,
lib/cachew/adapters.rb,
lib/cachew/adapters/base_adapter.rb,
lib/cachew/adapters/hash_adapter.rb,
lib/cachew/adapters/null_adapter.rb

Overview

Unified cache interface

Defined Under Namespace

Modules: Adapters

Constant Summary collapse

VERSION =
"0.1.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store = nil) ⇒ Cachew

Returns a new instance of Cachew.



10
11
12
# File 'lib/cachew.rb', line 10

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

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



8
9
10
# File 'lib/cachew.rb', line 8

def adapter
  @adapter
end

Instance Method Details

#fetch(key) ⇒ Object



14
15
16
# File 'lib/cachew.rb', line 14

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