Skip to content
Browse files

support for :pool_name option when initializing client (allows multip…

…le pools within a single runtime)
  • Loading branch information...
1 parent 8c2a2fa commit 00fe86c9fc0e90c883f468ab42e2914a879b6f20 Lennon Day-Reynolds committed Mar 13, 2009
Showing with 15 additions and 3 deletions.
  1. +10 −3 lib/j_mem_cache.rb
  2. +5 −0 spec/jruby_memcache_spec.rb
View
13 lib/j_mem_cache.rb
@@ -20,7 +20,8 @@ class JMemCache
:pool_maintenance_thread_sleep => 30,
:pool_use_nagle => false,
:pool_socket_timeout => 3000,
- :pool_socket_connect_timeout => 3000
+ :pool_socket_connect_timeout => 3000,
+ :pool_name => 'default'
}
## CHARSET for Marshalling
@@ -52,6 +53,11 @@ class JMemCache
# The servers this client talks to. Play at your own peril.
attr_reader :servers
+
+ ##
+ # The configured socket pool name for this client.
+
+ attr_reader :pool_name
def initialize(*args)
@servers = []
@@ -77,15 +83,16 @@ def initialize(*args)
opts = DEFAULT_OPTIONS.merge opts
@namespace = opts[:namespace] || opts["namespace"]
+ @pool_name = opts[:pool_name] || opts["pool_name"]
- @client = MemCachedClient.new
+ @client = MemCachedClient.new(@pool_name)
@client.primitiveAsString = true
@client.sanitizeKeys = false
weights = Array.new(@servers.size, DEFAULT_WEIGHT)
- @pool = SockIOPool.getInstance
+ @pool = SockIOPool.getInstance(@pool_name)
unless @pool.initialized?
# // set the servers and the weights
@pool.servers = @servers.to_java(:string)
View
5 spec/jruby_memcache_spec.rb
@@ -32,6 +32,11 @@
@client = JMemCache.new [ @server ], :namespace => 'test'
@client.servers.should == [ @server ]
end
+
+ it "should work with an explicit pool name" do
+ @client = JMemCache.new([@server], :pool_name => 'new_pool')
+ @client.pool_name.should == 'new_pool'
+ end
end
describe "namespacing" do

0 comments on commit 00fe86c

Please sign in to comment.
Something went wrong with that request. Please try again.