喜欢编程的鱼
oop_ming
全部博文(606)
UML(1)
文本分类(2)
Apache Http serv(2)
JProfiler(3)
Apache Lucene Ma(1)
googleapi(3)
nutch(10)
heritrix(1)
lucene(7)
J2EE模式(2)
行为模式(4)
结构模式(1)
创建模式(3)
FreeMarker(1)
Weblogic(3)
JSF(1)
Ajax(12)
Tomcat(5)
xml(6)
servlet(4)
JSP(19)
css(2)
javascript(30)
html(5)
Flex Builder(10)
NetBeans(0)
eclipse(28)
Linux(24)
windows(2)
Solaris(4)
Memcached(2)
NoSQL(0)
MS SQL(18)
MySQL(13)
Oracle(32)
iBATIS(1)
junit(3)
J2ME(1)
SWT(2)
webservice(17)
quartz(6)
J2EE(11)
J2SE(80)
面试题集(2)
问题集锦(1)
其他(8)
ANT(3)
jboss(1)
hibernate(56)
spring(33)
struts(23)
2011年(10)
2010年(67)
2009年(155)
2008年(386)
时间看来
梦醒潇湘
妤傛ê鍋
a8050366
abin1703
cynthia
Bsolar
1234fifa
dgsucces
belaxx
ousky
xutlong
分类: 数据库开发技术
2010-08-18 16:54:44
package client;import com.danga.MemCached.MemCachedClient;import com.danga.MemCached.SockIOPool;public class TestMemcached { public static void main(String[] args) { /** 初始化SockIOPool,管理memcached的连接池 **/ String[] servers = { "192.168.0.173:12000" }; SockIOPool pool = SockIOPool.getInstance(); pool.setServers(servers); pool.setFailover(true); pool.setInitConn(10); pool.setMinConn(5); pool.setMaxConn(250); pool.setMaintSleep(30); pool.setNagle(false); pool.setSocketTO(3000); pool.setAliveCheck(true); pool.initialize(); /** 建立MemcachedClient实例 **/ MemCachedClient memCachedClient = new MemCachedClient(); for (int i = 0; i < 10; i++) { /** 将对象加入到memcached缓存 **/ boolean success = memCachedClient.set("" + i, "Hello!"); /** 从memcached缓存中按key值取对象 **/ String result = (String) memCachedClient.get("" + i); System.out.println(String.format("set( %d ): %s", i, success)); System.out.println(String.format("get( %d ): %s", i, result)); } } }
log4j:WARN No appenders could be found for logger (com.danga.MemCached.SockIOPool).log4j:WARN Please initialize the log4j system properly.set( 0 ): trueget( 0 ): set( 1 ): trueget( 1 ): set( 2 ): trueget( 2 ): set( 3 ): trueget( 3 ): set( 4 ): trueget( 4 ): set( 5 ): trueget( 5 ): set( 6 ): trueget( 6 ): set( 7 ): trueget( 7 ): set( 8 ): trueget( 8 ): set( 9 ): trueget( 9 ):
上一篇:Linux下 Memcached 服务端安装配置
下一篇:linux 内存查看命令free详解
登录 注册