mirror of
https://github.com/dkam/suo.git
synced 2025-01-29 07:42:43 +00:00
29 lines
534 B
Ruby
29 lines
534 B
Ruby
module Suo
|
|
module Client
|
|
class Memcached < Base
|
|
def initialize(options = {})
|
|
options[:client] ||= Dalli::Client.new(options[:connection] || ENV["MEMCACHE_SERVERS"] || "127.0.0.1:11211")
|
|
super
|
|
end
|
|
|
|
def clear(key)
|
|
@client.delete(key)
|
|
end
|
|
|
|
private
|
|
|
|
def get(key)
|
|
@client.get_cas(key)
|
|
end
|
|
|
|
def set(key, newval, cas)
|
|
@client.set_cas(key, newval, cas)
|
|
end
|
|
|
|
def set_initial(key)
|
|
@client.set(key, "")
|
|
end
|
|
end
|
|
end
|
|
end
|