Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix tests, and shim for old memcached support

  • Loading branch information...
commit b8ed0c306d4f9ed6d04ac7ac17a8b46cea699dcf 1 parent b70f450
@freels authored
Showing with 18 additions and 7 deletions.
  1. +14 −3 lib/kestrel/client.rb
  2. +4 −4 spec/kestrel/client_spec.rb
View
17 lib/kestrel/client.rb
@@ -62,9 +62,20 @@ def get_from_random(key, raw=false)
rescue Memcached::NotFound
end
- def get_from_last(key, raw=false)
- super key, !raw
- rescue Memcached::NotFound
+ # use get_from_last if available, otherwise redefine to point to
+ # plain old get
+ if method_defined? :get_from_last
+ def get_from_last(key, raw=false)
+ super key, !raw
+ rescue Memcached::NotFound
+ end
+ else
+
+ $stderr.puts "You have an older version of memcached.gem. Please upgrade to 0.19.6 or later for sticky get behavior."
+ def get_from_last(key, raw=false)
+ _super_get_from_random key, !raw
+ rescue Memcached::NotFound
+ end
end
def delete(key, expiry=0)
View
8 spec/kestrel/client_spec.rb
@@ -18,15 +18,15 @@
end
it "gets from the same server :gets_per_server times" do
- mock(@kestrel).get_from_last("a_queue/t=250", false).times(100) { 'item' }
- mock(@kestrel).get_from_random("a_queue/t=250", false).times(2) { 'item' }
+ mock(@kestrel).get_from_last("a_queue/t=10", false).times(100) { 'item' }
+ mock(@kestrel).get_from_random("a_queue/t=10", false).times(2) { 'item' }
102.times { @kestrel.get("a_queue") }
end
it "gets from a different server when the last result was nil" do
- mock(@kestrel).get_from_last("a_queue/t=250", false).never { nil }
- mock(@kestrel).get_from_random("a_queue/t=250", false).times(3) { nil }
+ mock(@kestrel).get_from_last("a_queue/t=10", false).never { nil }
+ mock(@kestrel).get_from_random("a_queue/t=10", false).times(3) { nil }
3.times { @kestrel.get("a_queue") }
end
Please sign in to comment.
Something went wrong with that request. Please try again.