class Suo::Client::Memcached
Public Class Methods
new(key, options = {})
click to toggle source
Calls superclass method
Suo::Client::Base::new
# File lib/suo/client/memcached.rb, line 4 def initialize(key, options = {}) options[:client] ||= Dalli::Client.new(options[:connection] || ENV["MEMCACHE_SERVERS"] || "127.0.0.1:11211") super end
Public Instance Methods
clear()
click to toggle source
# File lib/suo/client/memcached.rb, line 9 def clear @client.with { |client| client.delete(@key) } end
Private Instance Methods
get()
click to toggle source
# File lib/suo/client/memcached.rb, line 15 def get @client.with { |client| client.get_cas(@key) } end
initial_set(val = BLANK_STR)
click to toggle source
# File lib/suo/client/memcached.rb, line 27 def initial_set(val = BLANK_STR) @client.with do |client| client.set(@key, val) _val, cas = client.get_cas(@key) cas end end
set(newval, cas, expire: false)
click to toggle source
# File lib/suo/client/memcached.rb, line 19 def set(newval, cas, expire: false) if expire @client.with { |client| client.set_cas(@key, newval, cas, @options[:ttl]) } else @client.with { |client| client.set_cas(@key, newval, cas) } end end