Class: Gateway::Memcache

Inherits:
Base
  • Object
show all
Defined in:
lib/gateway/memcache.rb

Instance Method Summary collapse

Instance Method Details

#default_expirationObject



25
26
27
# File 'lib/gateway/memcache.rb', line 25

def default_expiration
  options.fetch :expiration, 0
end

#get(id, raw = false) ⇒ Object



9
10
11
12
13
14
# File 'lib/gateway/memcache.rb', line 9

def get(id, raw = false)
  opts = {:retry => false}
  execute(:get, id, opts) do |conn|
    conn.get(id, raw)
  end
end

#set(id, value, expiration = nil, raw = false) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/gateway/memcache.rb', line 16

def set(id, value, expiration=nil, raw = false)
  opts = {:retry => false}
  ttl = expiration || default_expiration

  execute(:set, id, opts) do |conn|
    conn.set(id, value, ttl, raw)
  end
end