Class: Wrest::Caching::Memcached

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

Instance Method Summary (collapse)

Constructor Details

- (Memcached) initialize(server_urls = nil, options = {})



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

- (Object) [](key)



17
18
19
# File 'lib/wrest/caching/memcached.rb', line 17

def [](key)
  @memcached.get(key)
end

- (Object) []=(key, value)



21
22
23
# File 'lib/wrest/caching/memcached.rb', line 21

def []=(key, value)
  @memcached.set(key, value)
end

- (Object) delete(key)

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