zoukankan      html  css  js  c++  java
  • 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      连接最长时限
  • 相关阅读:
    mysql 5.7 安装手册(for linux)
    Git服务器分类
    Git服务器安装详解及安装遇到问题解决方案
    使用git进行版本管理
    Git 忽略一些文件不加入版本控制
    Windows下搭建基于SSH的Git服务器
    linux系统下mysql跳过密码验证登录和创建新用户
    阅读《不止代码》之心得分享
    Sonar安装和常见问题解决
    Eclipse安装Sonarlint插件
  • 原文地址:https://www.cnblogs.com/xmaomao/p/3337514.html
Copyright © 2011-2022 走看看