一:安装

(临时获取上手windows实验)

1.下载memcached.exe , 上F:\memcached\ 下

2.在CMD在输入 "F:\memcached\memcached.exe -d install" 安装.

3.再输入:"F:\memcached\memcached.exe -d start" 启动。以后memcached将作为windows的一个服务每次开机时自己主动启动。

这样server端已经安装完成了。

二:java引包

下面的包都是网上找的, 传说是阿里某高人封的

alisoft-xplatform-asf-cache-2.5.1.jar

hessian-3.0.1.jar

stax-api-1.0.1.jar

wstx-asl-2.0.2.jar

三:測试文件

package com.xxx.util;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient;
import com.alisoft.xplatform.asf.cache.memcached.client.SockIOPool;
import com.xxx.entity.attrGrid.Records; public class MemcachedManager
{
//创建MemCachedClient全局对象
private static MemCachedClient mcc = new MemCachedClient(); static
{
//创建服务器列表及其权重
String[] servers = {"127.0.0.1:11211"};
Integer[] weights = {3}; //创建Socket连接池对象
SockIOPool pool = SockIOPool.getInstance(); //设置服务器信息
pool.setServers(servers);
pool.setWeights(weights);
pool.setFailover(true); //设置初始连接数、最小和最大连接数以及最大处理时间
pool.setInitConn(5);
pool.setMinConn(5);
pool.setMaxConn(250);
pool.setMaxIdle(1000*60*60*6); //设置主线程睡眠时间
pool.setMaintSleep(30); //设置TCP參数、连接超时等
pool.setNagle(false);
pool.setSocketTO(3000);
pool.setSocketConnectTO(0);
pool.setAliveCheck(true); //初始化连接池
pool.initialize(); //压缩设置。超过指定大小(单位为K)的数据都会被压缩
mcc.setCompressEnable(true);
mcc.setCompressThreshold(64 * 1024);
} /**
* 无參构造
*/
protected MemcachedManager ()
{
} protected static MemcachedManager instance = new MemcachedManager();//单例
public static MemcachedManager getInstance ()
{
return instance;
} /**
* 加入对象到缓存中。构成方法重载
* @param key
* @param value
* @return
*/
public boolean add(String key,Object value)
{
return mcc.add(key, value);
}
public boolean add (String key,Object value,Date expiry)
{
return mcc.add(key, value,expiry);
}
public boolean replace (String key,Object value)
{
return mcc.replace(key, value);
}
public boolean replace (String key,Object value,Date expiry)
{
return mcc.replace(key, value, expiry);
} /**
* 依据指定的keyword获取对象
*/
public Object get(String key) {
return mcc.get(key);
} /**
* 利用MemCached对象将集合存入缓存。并从缓存中取出
*/
public static void main(String[] args)
{
//得到MemcachedManager实例
MemcachedManager cache = MemcachedManager.getInstance(); //1插入
List<Records> recordsList = new ArrayList<Records>();
for( int i =0 ; i<5 ; i++ )
{
Records records = new Records();
records.setPageSize(i); recordsList.add(records);
cache.add("SELECT aaa FROM bbb WHERE "+i,records);
}
System.out.println("插入完毕==>"); //2获取
for( int i =0 ; i<9 ; i++ )
{
Records records = (Records)cache.get("SELECT aaa FROM bbb WHERE "+i); if( null == records )
{
System.out.println("dao层 再去查");
}
else
{
String str = records.getPageSize().toString();
System.out.println("从缓存中取得的集合为:" + str);
}
}
}
}

四:现象

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.impl.DefaultCacheImpl - DefaultCache CheckService is start!

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ serializing for key: SELECT+aaa+FROM+bbb+WHERE+0 for class: com.tianditu.entity.attrGrid.Records

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ memcache cmd (result code): add SELECT+aaa+FROM+bbb+WHERE+0 8 0 451

 (STORED)

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ data successfully stored for key: SELECT+aaa+FROM+bbb+WHERE+0

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ serializing for key: SELECT+aaa+FROM+bbb+WHERE+1 for class: com.tianditu.entity.attrGrid.Records

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ memcache cmd (result code): add SELECT+aaa+FROM+bbb+WHERE+1 8 0 451

 (STORED)

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ data successfully stored for key: SELECT+aaa+FROM+bbb+WHERE+1

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ serializing for key: SELECT+aaa+FROM+bbb+WHERE+2 for class: com.tianditu.entity.attrGrid.Records

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ memcache cmd (result code): add SELECT+aaa+FROM+bbb+WHERE+2 8 0 451

 (STORED)

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ data successfully stored for key: SELECT+aaa+FROM+bbb+WHERE+2

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ serializing for key: SELECT+aaa+FROM+bbb+WHERE+3 for class: com.tianditu.entity.attrGrid.Records

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ memcache cmd (result code): add SELECT+aaa+FROM+bbb+WHERE+3 8 0 451

 (STORED)

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ data successfully stored for key: SELECT+aaa+FROM+bbb+WHERE+3

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ serializing for key: SELECT+aaa+FROM+bbb+WHERE+4 for class: com.tianditu.entity.attrGrid.Records

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ memcache cmd (result code): add SELECT+aaa+FROM+bbb+WHERE+4 8 0 451

 (STORED)

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ data successfully stored for key: SELECT+aaa+FROM+bbb+WHERE+4

插入完毕==>

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ deserializing class com.tianditu.entity.attrGrid.Records

从缓存中取得的集合为:0

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ deserializing class com.tianditu.entity.attrGrid.Records

从缓存中取得的集合为:1

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ deserializing class com.tianditu.entity.attrGrid.Records

从缓存中取得的集合为:2

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ deserializing class com.tianditu.entity.attrGrid.Records

从缓存中取得的集合为:3

2014 14:30:31 INFO  com.alisoft.xplatform.asf.cache.memcached.client.MemCachedClient - ++++ deserializing class com.tianditu.entity.attrGrid.Records

集合被从缓存制成:4

dao层 去检查

dao层 去检查

dao层 去检查

dao层 去检查

java + memcached安装的更多相关文章

  1. 安装java memcached client到本地maven repository

    由于目前java memcached client没有官方的maven repository可供使用,因此使用时需要手动将其安装到本地repository.java memcached client的 ...

  2. linux下memcached安装 和redis安装,jdk,tomcat,mysql 安装

    一.memcached安装yum  search  memcachedyum  -y install memcachedmemmcached -h service memcached restartc ...

  3. Linux Memcached安装以及PHP扩展安装

    一:安装libevent 由于memcached安装时,需要使用libevent类库,所以先安装libevent 1.下载 #wget   http://www.monkey.org/~provos/ ...

  4. linux下memcached安装以及启动

    1. 准备安装文件 下载memcached与libevent的安装文件 http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz(me ...

  5. Win2008R2+java+tomcat安装

    Win2008R2+java+tomcat安装 准备软件: jdk-7u25-windows-x64.exe apache-tomcat-7.0.42-windows-x64.zip 一.安装java ...

  6. memcached安装

    memcached安装 一.安装gcc # yum -y install gcc 二.安装libevent # wget http://www.monkey.org/~provos/libevent- ...

  7. 【转】Memcached安装

    解析:Memcached是什么? Memcached是由Danga Interactive开发的,高性能的,分布式的内存对象缓存系统,用于在动态应用中减少数据库负载,提升访问速度. 一.软件版本    ...

  8. 初学Memcached安装及使用(CentOS7)

    1.yum install memcached安装memecached 2.chkconfig memcached on设置memcached开机启动 3.service memcached star ...

  9. Linux下memcached安装和启动方法

    Linux下memcached安装和启动方法 1. 首先下载memcached 和 libevent 包. Memcached用到了libevent这个库用于Socket的处理.下面是下载的两个包文件 ...

随机推荐

  1. Windows 8 和 Windows 8.1 中对插件和 ActiveX 的支持

    此文章将介绍页面在 Windows 8 适用于桌面版的 Internet Explorer 中与在新 Windows UI 的 Internet Explorer 中的不同表现. Windows 8 ...

  2. 【设计模式】Singleton模式C++实现

    Singleton是设计模式中比较简单的一个.园中的朋友们应该都很熟悉了.前段时间参加xxx外企的面试,和面试官讨论C++的时候正好写了一个.当时由于在有些地方考虑不太周全,代码出现了一些疏漏.不过最 ...

  3. STM8S 串口应用 UART2 STM8S105

    //少说话.多做事,下面是我验证过没有问题的串口发送接受数据 //使用MCU stm8s105c6 UART2 //初始化时调用: GPIO_DeInit(GPIOD); /* Configure P ...

  4. 2388 Who&#39;s in the Middle(简单排序)

    训练计划的第一个问题,首先从水问题开始:排序的数组,中间数则输出. http://poj.org/problem?id=2388 冒泡排序: #include <iostream> usi ...

  5. Swift - 使用网格(UICollectionView)进行流布局

    一.网格UICollectionView最典型的例子是iBooks.其主要属性如下: 1,layout 该属性表示布局方式,有Flow.Custom两种布局方式.默认是Flow流式布局. 2,Acce ...

  6. [Python 学习]2.5版yield之学习心得 - limodou的学习记录 - limodou是一个程序员,他关心的焦点是Python, DocBook, Open Source …

    [Python 学习]2.5版yield之学习心得 - limodou的学习记录 - limodou是一个程序员,他关心的焦点是Python, DocBook, Open Source - [Pyth ...

  7. MySQL HINT:Straight_JOIN

    来自生产环境的朋友.可能都会碰到:          原本运行良好的查询语句,过了一段时间后,可能会突然变得很糟糕     一个很大可能的原因就是数据分布情况发生了变化     从而导致MySQL优化 ...

  8. [Android学习笔记]Unable to execute dex Multiple dex files define:xxxx 问题

    dex filse: Dalvik Execute Files , 即Android虚拟机可执行程序 从字面意思理解是你一个应用中,出现了多个Dex文件定义. 以下情况会出现此错误: 1.你项目中可能 ...

  9. 摘要算法CRC8、CRC16、CRC32,MD2 、MD4、MD5,SHA1、SHA256、SHA384、SHA512,RIPEMD、PANAMA、TIGER、ADLER32

    1.CRC8.CRC16.CRC32 CRC(Cyclic Redundancy Check,循环冗余校验)算法出现时间较长,应用也十分广泛,尤其是通讯领域,现在应用最多的就是 CRC32 算法,它产 ...

  10. VMware vSphere服务器虚拟化实验十五 vCenter vShield Manager

    VMware vSphere服务器虚拟化实验十五 vCenter vShield Manager VMware  vShield Manager是专为 VMware vCenter Server 集成 ...