Class: Wrest::Caching::Memcached

Inherits:
Object
  • Object
show all
Defined in:
lib/wrest/caching/memcached.rb

Instance Method Summary collapse

Constructor Details

#initialize(server_urls = nil, options = {}) ⇒ Memcached



13
14
15
# File 'lib/wrest/caching/memcached.rb', line 13

def initialize(server_urls=nil, options={})
  @memcached = Dalli::Client.new(server_urls, options)
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