Permalink
Browse files

yeah, use the hacked KetamaMemcachedSessionLocator

  • Loading branch information...
1 parent 9301d65 commit adb38ce923dd54513e5a10d909c7df6e048914b8 @flyerhzm flyerhzm committed Jul 23, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/memcached.rb
View
@@ -6,9 +6,8 @@
class Memcached
include_class 'net.rubyeye.xmemcached.XMemcachedClientBuilder'
include_class 'net.rubyeye.xmemcached.utils.AddrUtil'
- include_class 'net.rubyeye.xmemcached.impl.LibmemcachedMemcachedSessionLocator'
- include_class 'net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator'
include_class 'net.rubyeye.xmemcached.HashAlgorithm'
+ include_class 'com.openfeint.memcached.impl.KetamaMemcachedSessionLocator'
include_class 'com.openfeint.memcached.transcoders.SimpleTranscoder'
FLAGS = 0x0
@@ -22,7 +21,7 @@ class Memcached
def initialize(addresses, options={})
builder = XMemcachedClientBuilder.new AddrUtil.getAddresses(Array(addresses).join(' '))
- builder.setSessionLocator(LibmemcachedMemcachedSessionLocator.new(100, HashAlgorithm::FNV1_32_HASH))
+ builder.setSessionLocator(KetamaMemcachedSessionLocator.new(HashAlgorithm::FNV1_32_HASH))
@client = builder.build
@options = DEFAULTS.merge(options)
@@ -33,6 +32,10 @@ def initialize(addresses, options={})
@simple_transcoder = SimpleTranscoder.new
end
+ def servers
+ @client.available_servers.map { |server| server.to_s.split("/").last }
+ end
+
def set(key, value, ttl=@default_ttl, marshal=true, flags=FLAGS)
with_retry do
value = encode(value, marshal, flags)

0 comments on commit adb38ce

Please sign in to comment.