John, we initiate in our tomcat instance in the following manner:<br><br> protected static MemCachedClient mcc = new MemCachedClient();<br> static {<br> // get mcache servers<br> String[] serverlist = Global.getInstance
().getProperty( "memcached.servers" ).split( "," );<br><br> // get server weights<br> Integer[] weights = new Integer[serverlist.length];<br> String[] serverWeights = Global.getInstance
().getProperty( "memcached.servers.weights" ).split( "," );<br> for ( int i = 0; i < serverWeights.length; i++ ) {<br> weights[i] = new Integer( serverWeights[i] );<br> }<br>
<br> // get compression threshhold<br> int bytes = Integer.parseInt( Global.getInstance().getProperty( "memcached.compress.kbytes" ) );<br><br> // idle time set to 4 hours<br> long maxIdle = 1000 * 60 * 60 * 6;
<br><br> // socket read timeout<br> int readTO = 1000 * 3;<br> <br> // initialize the pool for memcache servers<br> // see javadocs on this method<br> // for tuning the connection pool
<br> SockIOPool pool = SockIOPool.getInstance();<br> pool.setServers( serverlist );<br> pool.setWeights( weights );<br> pool.setInitConn( 10 );<br> pool.setMinConn( 5 );<br> pool.setMaxConn
( 250 );<br> pool.setMaintSleep( 30 );<br> pool.setNagle( false );<br> pool.setSocketTO( readTO );<br> pool.setSocketConnectTO( 0 );<br> pool.setMaxIdle( maxIdle );<br> pool.initialize
();<br><br> // no running w/compression for now<br> if ( bytes > 0 ) {<br> mcc.setCompressEnable( true );<br> mcc.setCompressThreshold( bytes * 1024 );<br> }<br> else {
<br> mcc.setCompressEnable( false );<br> }<br> }<br><br>In this class we then have some helper methods to get/put using the mcc object. Hope this helps.<br><br>Greg<br><br><div><span class="gmail_quote">
On 2/6/07, <b class="gmail_sendername">John Navil Joseph</b> <<a href="mailto:navil.john@gmail.com">navil.john@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Please correct me if I am wrong.<br><br>Ideally there should be a single memcached connection pool available<br>in the web server, and it should be made available to the servlets<br>through the initial context.<br><br>For example this is the way I connect to my MySQL databases, by making
<br>use of a connection that I get from the existing connection pool.<br><br> Context initCtx = new InitialContext();<br> Context envCtx = (Context) initCtx.lookup("java:comp/env");<br><br> DataSource ds = (DataSource)
<br> envCtx.lookup("jdbc/TestDB");<br><br> Connection conn = ds.getConnection();<br><br>I know it is possible to achieve the same functionality with the<br>SockIOPool as well. But how exactly do I use SockIOPool in the web
<br>server?<br><br>Thanks,<br>John<br><br>On 2/6/07, Gabe Schine <<a href="mailto:gabe.schine@gmail.com">gabe.schine@gmail.com</a>> wrote:<br>> we have been using that combination for a while now:<br>><br>> about 16 clients (load-balanced web servers) and 1 server. works
<br>> great for us. we are using SockIOPool, as well -- what would you like<br>> to know?<br>><br>> gabe<br>><br>><br>> On Feb 5, 2007, at 9:47 PM, John Navil Joseph wrote:<br>><br>> > Newbie to memcached here!
<br>> ><br>> > Has anyone been using the java memcached client (available<br>> > @<a href="http://whalin.com">whalin.com</a>) with Apache Tomcat? Just interested in knowing how<br>> > tried and tested/widely deployed the combination is.
<br>> ><br>> > Also some pointers on using the SockIOPool connection pool<br>> > mechanism with Tomcat will be helpful.<br>> ><br>> > Thanks,<br>> > John<br><br></blockquote></div><br><br clear="all">
<br>-- <br>Greg Whalin