Skip to content

Commit

Permalink
yeah, use the hacked KetamaMemcachedSessionLocator
Browse files Browse the repository at this point in the history
  • Loading branch information
flyerhzm committed Jul 23, 2012
1 parent 9301d65 commit adb38ce
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/memcached.rb
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit adb38ce

Please sign in to comment.