MemCached用法
所需要的jar包:
com.danga.MemCached.MemCachedClient
com.danga.MemCached.SockIOPool 自行下载
/**
* 缓存服务器集群,提供缓存连接初始化,获取缓存客户端等工作
* @author ray
*/
public class CacheCluster
{
private final static MemCachedClient client = new MemCachedClient();
private static String _memcache_config = "/WEB-INF/config/memcached.properties"; static
{
Properties config = FileUtil.getProperties(HttpContext.getPathPrefix() + _memcache_config);
String serverGroup = config.getProperty("server");
String[] servers = serverGroup.split(";"); SockIOPool pool = SockIOPool.getInstance();
int init_conns = Integer.valueOf(config.getProperty("conn_init"));
int min_spare = Integer.valueOf(config.getProperty("conn_minspare"));
int max_spare = Integer.valueOf(config.getProperty("conn_maxspare"));
long idel_time = Long.valueOf(config.getProperty("conn_maxideltime"));
long busy_time = Long.valueOf(config.getProperty("conn_maxbusytime"));
int timeout = Integer.valueOf(config.getProperty("conn_timeout"));
pool.setServers(servers);
pool.setInitConn(init_conns);
pool.setMinConn(min_spare);
pool.setMaxConn(max_spare);
pool.setMaxIdle(idel_time);
pool.setMaxBusyTime(busy_time);
pool.setSocketTO(timeout);
pool.setFailover(true);
pool.initialize(); client.setCompressEnable(true);
client.setCompressThreshold(64 * 1024);
} public static MemCachedClient getCacheClient()
{
return client;
}
}
properties配置文件:
server=192.168.11.144:1121
conn_init=100 初始化空间大小kb
conn_minspare=100 最小分配空间kb
conn_maxspare=1000 cache空间kb
conn_maxideltime=1800000
conn_maxbusytime=300000 最长连接数量
conn_timeout=3000 连接最长时限
MemCached用法的更多相关文章
- (转)Memcached用法--参数和命令详解
Memcached用法--参数和命令详解 1. memcached 参数说明: # memcached -h 1.1 memcached 的参数 常用参数 -p <num> 监听的TCP端 ...
- php Memcache/Memcached操作手册
php Memcache/Memcached使用教程 Memcache和Memcached 其实是一个东西,只是php中要是用的扩展不一样, 2009年左右有人丰富memcache的用法和性能,编写了 ...
- Memcache/Memcached的PHP操作手册(纯手稿版)
Memcache和Memcached 其实是一个东西,只是php中要是用的扩展不一样, 2009年左右有人丰富memcache的用法和性能,编写了一个libmemcached是独立第三方client ...
- Memcache and Mongodb
转自:http://www.cnblogs.com/lovecindywang/archive/2010/05/19/1739025.html 先说说自己对Memcache和Mongodb的一些看法. ...
- Mac linux 安装memcached服务 用法
今天在Mac上安装memcached服务的时候 由于安装memcached之前需要安装libevent依赖包 所以使用brew install libevent 安装过程中报错 Warning: Yo ...
- Memcached命令:简单获取缓存value用法
Memcached:命令用法1.cmd 输入telnet ip 端口 进入memcached服务端窗口比如:xxx.Token_T1435622096xxx为key获取此key的memcached ...
- MemCached add命令的用法详解
增加: add 往内存增加一条数据 命令格式: add key flag expiretime bytes\r\n data\r\n //跨行所加的一些数据 1)key: 给这个值起一个固定的名字 / ...
- Memcached操作以及用法
Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度.Memcached ...
- Memcached部署和用法
一.Memcached简介 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网 ...
随机推荐
- [MFC] CList
1.CList说明 类CList支持可按顺序或按值访问的非唯一对象的有序列表.CList 列表与双链接列表行为相似. template < class TYPE, class ARG_TYPE ...
- SharePoint 基于 REST API使用简介
之前已经介绍了SP2010中支持CSOM的API进行远程访问SharePoint,但是CSOM的API仍然有一定的局限性,首先使用CSOM类库是基于.Net的,因此也将使用CSOM限制在了.Net平台 ...
- paip.spring3 mvc servlet的配置以及使用最佳实践
paip.spring3 mvc servlet的配置以及使用最佳实践 1. Web.xml 1 2. springMVC.xml 2 1. mvcAction .mvcAction 2 2. Res ...
- Oracle数据库恢复
建用户 wf2014 赋权限 grant dba to wf2014; 数据恢复 imp wf2014/wf2014 file=D:\wf2014.dmp full=y 参数设置: datasourc ...
- 在C#中如何读取枚举值的描述属性
在C#中,有时候我们需要读取枚举值的描述属性,也就是说这个枚举值代表了什么意思.比如本文中枚举值 Chinese ,我们希望知道它代表意思的说明(即“中文”). 有下面的枚举: 1 2 3 4 5 6 ...
- linux用shell腳本解决被ddos攻击的问题
最近网站常常被人DDOS所以写了一个小程序用来自动封锁IP,代码如下: !/bin/bash for (( ; ; )) do status=netstat -na|grep ESTABLISHED| ...
- NEWS - InstallShield 2014正式发布
InstallShield又迎来了新的版本InstallShield 2014,开发版本号Ver 21.0,相关产品信息已经可以从厂商Flexera Software(富莱睿)官方网站获得. 对于中国 ...
- ssh sftp scp命令
scp local_file remote_username@remote_ip:remote_folder 或者 scp local_file remote_username@remote_ip:r ...
- GTD中定位篇
一:为什么要定位? 每天我们的大脑涌现很多想法和要处理很多事情,如果我们没有一套流模式处理这些想法和事情,我们大脑将会处于混战忙碌中,很快就被淹没. 定位的目的: 就是有一套流模式有序的分界我们想法和 ...
- IOC性能对比