Class: Messed::Session::Memcache
- Inherits:
-
Messed::Session
- Object
- Messed::Session
- Messed::Session::Memcache
- Defined in:
- lib/messed/session/memcache.rb
Instance Method Summary collapse
-
#initialize(config = "127.0.0.1:11211") ⇒ Memcache
constructor
A new instance of Memcache.
- #reset!(id) ⇒ Object
- #with(id) ⇒ Object
Constructor Details
#initialize(config = "127.0.0.1:11211") ⇒ Memcache
Returns a new instance of Memcache.
9 10 11 |
# File 'lib/messed/session/memcache.rb', line 9 def initialize(config = "127.0.0.1:11211") @connection = Memcached.new(config) end |
Instance Method Details
#reset!(id) ⇒ Object
13 14 15 |
# File 'lib/messed/session/memcache.rb', line 13 def reset!(id) connection.delete(id) end |
#with(id) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/messed/session/memcache.rb', line 17 def with(id) data = data(id) begin yield data ensure connection.set(key(id), data.to_json) end end |