Class: SpeedGun::Store::Memcache
- Inherits:
-
Object
- Object
- SpeedGun::Store::Memcache
- Defined in:
- lib/speed_gun/store/memcache.rb
Constant Summary collapse
- DEFAULT_PREFIX =
'speed-gun-'
- DEFAULT_EXPIRES_IN_SECONDS =
60 * 60 * 24
Instance Method Summary collapse
- #[](id) ⇒ Object
- #[]=(id, val) ⇒ Object
-
#initialize(options = {}) ⇒ Memcache
constructor
A new instance of Memcache.
Constructor Details
#initialize(options = {}) ⇒ Memcache
Returns a new instance of Memcache.
7 8 9 10 11 |
# File 'lib/speed_gun/store/memcache.rb', line 7 def initialize( = {}) @prefix = [:prefix] || DEFAULT_PREFIX @client = [:client] || default_dalli @expires = [:expires] || DEFAULT_EXPIRES_IN_SECONDS end |
Instance Method Details
#[](id) ⇒ Object
13 14 15 |
# File 'lib/speed_gun/store/memcache.rb', line 13 def [](id) @client.get("#{@prefix}#{id}") end |
#[]=(id, val) ⇒ Object
17 18 19 |
# File 'lib/speed_gun/store/memcache.rb', line 17 def []=(id, val) @client.set("#{@prefix}#{id}", val, @expires) end |