Class: Cachew
- Inherits:
-
Object
- Object
- Cachew
- 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
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
- #fetch(key) ⇒ Object
-
#initialize(store = nil) ⇒ Cachew
constructor
A new instance of Cachew.
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
#adapter ⇒ Object (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 |