1、下载下面附件 memcached-1.2.1-win32.zip 和 memcached-release_1.6.zip 。解压到指定目录,cmd切换进解压后的 memcached-1.2.1-win32 目录,执行 memcached.exe -d install 和 memcached.exe -l 127.0.0.1 -m 32 -d start 命令。这里只为memcached分配32M内存,此时在“服务”中可以看到 memcached Server这个服务。
2、创建Server端代码往 memcached 中存放数值
package com.neusoft; import org.apache.log4j.BasicConfigurator; import com.danga.MemCached.MemCachedClient; import com.danga.MemCached.SockIOPool; public class ServerTest { public static void main(String[] args) { BasicConfigurator.configure(); String[] servers = {"127.0.0.1:11211"}; 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 = new MemCachedClient(); for ( int i = 0; i < 10; i++ ) { memCachedClient.set( "biao.li" + i, i+" >>> Hello!" ); } } }
3、创建Client代码获取memcached 中的数值
package com.neusoft; import org.apache.log4j.BasicConfigurator; import com.danga.MemCached.MemCachedClient; import com.danga.MemCached.SockIOPool; public class ClientTest { public static void main(String[] args) { BasicConfigurator.configure(); String[] servers = {"127.0.0.1:11211"}; 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 = new MemCachedClient(); for ( int i = 0; i < 10; i++ ) { Object obj = memCachedClient.get("biao.li" + i); System.out.println(obj); } } }
相关推荐
memcached-1.2.6-win32-bin window 上的安装与使用全过程.如果要例子也可以找我.
memcached官方window包,学习的基本入门包
打包里面包括以下内容: 1:java_memcached-release_2.6.3资料 2:alisoft-xplatform-asf-cache-2.5.1-src资料 3:memcached-1.2.1-win32安装文件 4:memcached-1.4.13源代: 5:demo
java 写的例子.里面是程序.如果要MemCached window安装文件也可以在资源中查.jar包是全的.
memcached 简单实用需要的 window memcached 安装文件以及 java 需要的jar 文件
有实例,window环境下安装包,安装文档,使用文档,LINUX下说明文档等等,基本上所有的东西都全了.如果还有少的,请大家帮忙补充谢谢.如果是在WINDOWS下测试,安装一下安装包然后执行实例就可以了,命令窗口不要...
memcached的基本设置:-p 监听的端口 -l 连接的IP地址, 默认是本机 -d start 启动memcached服务 -d restart 重起memcached服务 -d stop|shutdown 关闭正在运行的memcached服务 -d install 安装memcached服务 -d ...
redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部 分场合可以对关系数据库起到很好的补充作用。它提供了Java,C/C++,C#,PHP,JavaScript,Perl,Object-C,Python,Ruby,Erlang等客户端,...
Window7 我是在Win7上做的。不是什么Linux,网上好多资料,特别麻烦。 Nginx Nginx 比较好找到,直接去网上下载 网址: http://nginx.org/en/download.html 版本不作要求了,(比如1.2.9版本),都有。 JDK JAVA的...
由于微软对ASP.Net进行高度封装,因此ASP.Net入门非常简单,开发人员不需要了解HTML、JavaScript、Http协议也可以快速开发出一个Web系统,正因为如此,社会上充斥着大量这样的“拖控件的开发人员”,使得很多Java、...