mirror of
https://github.com/dkam/suo.git
synced 2025-01-29 07:42:43 +00:00
Add support for pooled memcached clients by using #with
This commit is contained in:
@@ -7,28 +7,30 @@ module Suo
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clear
|
def clear
|
||||||
@client.delete(@key)
|
@client.with { |client| client.delete(@key) }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get
|
def get
|
||||||
@client.get_cas(@key)
|
@client.with { |client| client.get_cas(@key) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(newval, cas, expire: false)
|
def set(newval, cas, expire: false)
|
||||||
if expire
|
if expire
|
||||||
@client.set_cas(@key, newval, cas, @options[:ttl])
|
@client.with { |client| client.set_cas(@key, newval, cas, @options[:ttl]) }
|
||||||
else
|
else
|
||||||
@client.set_cas(@key, newval, cas)
|
@client.with { |client| client.set_cas(@key, newval, cas) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initial_set(val = BLANK_STR)
|
def initial_set(val = BLANK_STR)
|
||||||
@client.set(@key, val)
|
@client.with do |client|
|
||||||
_val, cas = @client.get_cas(@key)
|
client.set(@key, val)
|
||||||
|
_val, cas = client.get_cas(@key)
|
||||||
cas
|
cas
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user