Memcached client for Java client API: memcached client for Java
Web: http://www.whalin.com/memcached
Mclient. Java
Package bcndyl. test; </P> <p> Import Org. springframework. context. applicationcontext; <br/> Import Org. springframework. context. support. filesystemxmlapplicationcontext; </P> <p> Import COM. danga. memcached. memcachedclient; </P> <p> public class mclient {</P> <p> Public static void main (string [] ARGs) {</P> <p> applicationcontext CTX = new filesystemxmlapplicationcontext ("src/applicationcontext. XML "); <br/> memcachedclient MC = (memcachedclient) CTX. getbean ("memcachedclient"); <br/> for (INT I = 0; I <100; I ++) {<br/> // try {thread. sleep (2000);} catch (exception e) {}< br/> MC. set ("Keya" + I, "value" + I); <br/>}< br/> try {thread. sleep (5000);} catch (exception e) {}< br/> for (INT I = 0; I <100; I ++) {<br/> system. out. println ("get" + I + "value" + MC. get ("key" + I); <br/>}</P> <p >}< br/>
Spring configuration file
<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <beans <br/> xmlns = "http://www.springframework.org/schema/beans" <br/> xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" <br/> xsi: schemalocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> </P> <p> <bean id = "memcachedpool" class = "com. danga. memcached. sockiopool "factory-method =" getinstance "<br/> init-method =" initialize "d Estroy-method = "shutdown"> <br/> <constructor-Arg> <value> neeamemcachedpool </value> </constructor-Arg> <br/> <property name =" servers "> <br/> <list> <br/> <value> 192.168.227.20: 12111 </value> <br/> <value> 192.168.227.20: 12112 </value> <br/> </List> <br/> </property> <br/> <property name = "initconn"> <value> 20 </value> </property> <br/> <property name = "minconn"> <value> 10 </value> </property> <br/> <property na Me = "maxconn"> <value> 50 </value> </property> <br/> <property name = "maintsleep"> <value> 30 </value> </ property> <br/> <property name = "Nagle"> <value> false </value> </property> <br/> <property name = "socketto"> <Value & gt; 3000 </value> </property> <br/> <! -- <Br/> <property name = "initconn"> <value> </property> <br/> <property name = "initconn"> <value> </value> </property> --> <br/> </bean> </P> <p> <bean id = "memcachedclient" class = "com. danga. memcached. memcachedclient "> <br/> <constructor-Arg> <value> neeamemcachedpool </value> </constructor-Arg> <br/> <property name =" compressenable "> <Value> true </value> </property> <br/> <property name = "compressthreshold"> <value> 4096 </value> </property> <br/> </ bean> </P> <p> </beans> <br/>