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应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网 ...
随机推荐
- Abp Application级别的生命周期
本篇级别: 中高级篇,假设各位知道Abp是什么, Abp里面的基本的概念及用法(想了解基本概念的可在这里学习: http://www.cnblogs.com/mienreal/p/4358806.ht ...
- 使用grunt打包ueditor源代码
支持版本支持 UEditor 1.3.0+ 的版本 使用方法1.线上下载ueditor下载地址:ueditor,要下载"完整版 + 源码" 2.安装nodejs下载nodejs并安 ...
- Paip.Php Java 异步编程。推模型与拉模型。响应式(Reactive)”编程FutureData总结... 1
Paip.Php Java 异步编程.推模型与拉模型.响应式(Reactive)"编程FutureData总结... 1.1.1 异步调用的实现以及角色(:调用者 提货单) F ...
- android定位GPS定位 代码实现
package com.lx.util; import android.content.Context; import android.content.SharedPreferences; imp ...
- Java thread jargon
In Java thread topic, the task to be executed and the thread to drive the task are two concepts shou ...
- This in JavaScript
声明 本文仅为读书笔记并致力于理解Js中的this关键字.如有雷同,纯属巧合.原因有二,其一:有幸看了同一本书,其二:this这玩意已被说烂了~ 为什么要用this? this提供了优雅的方式隐式传递 ...
- Struts2入门2 Struts2深入
Struts2入门2 Struts2深入 链接: http://pan.baidu.com/s/1rdCDh 密码: sm5h 前言: 前面学习那一节,搞得我是在是太痛苦了.因为在Web项目中确实不知 ...
- Hibernate入门6.Hibernate检索方式
Hibernate入门6.Hibernate检索方式 20131128 代码下载 链接: http://pan.baidu.com/s/1Ccuup 密码: vqlv Hibernate的整体框架已经 ...
- android: 从相册中选择照片
虽然调用摄像头拍照既方便又快捷,但并不是每一次我们都需要去当场拍一张照片的. 因为每个人的手机相册里应该都会存有许许多多张照片,直接从相册里选取一张现有的照 片会比打开相机拍一张照片更加常用.一个优秀 ...
- 巧用Windows 7计划任务设置定时提醒
Windows 7系统有个“计划任务”功能,一般人都很少使用.其实,“计划任务”是系统自带的一个很实用的功能,比如说,这个功能可以设置定时提醒,这样在使用电脑时就不会因为太过投入而导致错过重要的事务. ...