Class: Wrest::Caching::Memcached
- Inherits:
-
Object
- Object
- Wrest::Caching::Memcached
- Defined in:
- lib/wrest/caching/memcached.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#delete(key) ⇒ Object
should be compatible with Hash - return value of the deleted element.
-
#initialize(server_urls = nil, options = {}) ⇒ Memcached
constructor
A new instance of Memcached.
Constructor Details
#initialize(server_urls = nil, options = {}) ⇒ Memcached
Returns a new instance of Memcached.
13 14 15 |
# File 'lib/wrest/caching/memcached.rb', line 13 def initialize(server_urls=nil, ={}) @memcached = Dalli::Client.new(server_urls, ) end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 |
# File 'lib/wrest/caching/memcached.rb', line 17 def [](key) @memcached.get(key) end |
#[]=(key, value) ⇒ Object
21 22 23 |
# File 'lib/wrest/caching/memcached.rb', line 21 def []=(key, value) @memcached.set(key, value) end |
#delete(key) ⇒ Object
should be compatible with Hash - return value of the deleted element.
26 27 28 29 30 31 32 |
# File 'lib/wrest/caching/memcached.rb', line 26 def delete(key) value = self[key] @memcached.delete key return value end |