Skip to content

Commit

Permalink
Merge pull request #10 from levkk/levkk/support-pooled-clients
Browse files Browse the repository at this point in the history
Add support for pooled memcached clients by using #with
  • Loading branch information
nickelser authored Sep 4, 2019
2 parents b8a1d7d + 60e167e commit 270c05b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions lib/suo/client/memcached.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,29 @@ def initialize(key, options = {})
end

def clear
@client.delete(@key)
@client.with { |client| client.delete(@key) }
end

private

def get
@client.get_cas(@key)
@client.with { |client| client.get_cas(@key) }
end

def set(newval, cas, expire: false)
if expire
@client.set_cas(@key, newval, cas, @options[:ttl])
@client.with { |client| client.set_cas(@key, newval, cas, @options[:ttl]) }
else
@client.set_cas(@key, newval, cas)
@client.with { |client| client.set_cas(@key, newval, cas) }
end
end

def initial_set(val = BLANK_STR)
@client.set(@key, val)
_val, cas = @client.get_cas(@key)
cas
@client.with do |client|
client.set(@key, val)
_val, cas = client.get_cas(@key)
cas
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion suo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "redis"
spec.add_dependency "msgpack"

spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "bundler"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rubocop", "~> 0.49.0"
spec.add_development_dependency "minitest", "~> 5.5.0"
Expand Down

0 comments on commit 270c05b

Please sign in to comment.