# springMVCMybatisMemches
**Repository Path**: tHero/springMVCMybatisMemches
## Basic Information
- **Project Name**: springMVCMybatisMemches
- **Description**: memched 配置
- **Primary Language**: Java
- **License**: Not specified
- **Default Branch**: temp
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2016-03-16
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
#### 参考资料
如何对memcache的数据(key-value)进行遍历操作
http://kb.cnblogs.com/page/43350/
#### Memcached: List all keys
http://www.darkcoding.net/software/memcached-list-all-keys/
#### 依赖文件已经项目jar包
http://git.oschina.net/tHero/springMVCMybatisMemches/tree/temp/relation%20files?dir=1&filepath=relation+files&oid=ec61f21f8494c2c4eb4ae21b1cea938f91ff7985&sha=6f7e18dc689fa75494215a2970f2a7319964156e
### 测试方式:
1、 从http://git.oschina.net/tHero/springMVCMybatisMemches/tree/temp 下载该项目;
2、导入eclipse中;
3、部署到tomcat
4、启动memcache本地服务器;
5、启动tomcat
6、访问localhost:8071/smm/user地址;
7、使用项目中Telnet.java可以查看缓存在memcached中的user和list对象;
8、也可以使用telnet来连接到memcached来查询缓存中的对象;可以参考:http://blog.csdn.net/dc_726/article/details/9209401?utm_source=tuicool&utm_medium=referral文章来获取memcached的使用方法
### 代码解释
配置
====
`spring-memcached.xml`文件中主要配置了连接memcached的相关信息;
`127.0.0.1:11211
`包括连接池地址;
`initConn`初始化最大连接数
`minConn`最小连接数
`maxConn`最大连接数
对象
=====
需要在配置文件中配置`memcachedClient`对象,来提供给java对象使用;对象信息如下;
```
neeaMemcachedPool
```
代码引用
====
`add` 添加方法,将值添加到memcached中;
`set` 添加方法;
`get` 获取对象方法;
代示例
===
```
ModelAndView m = new ModelAndView();
MemCachedClient mc = SpringContextHolder.getBean("memcachedClient");
mc.add("user", "123");
mc.set("12", 12);
List s = new ArrayList();
s.add("123");
s.add("456");
mc.set("List", s);
Object o = mc.get("user");
System.out.println(o);
System.out.println("##############################");
for(int i=0; i<100; i++){
//try{Thread.sleep(2000);}catch(Exception e){}
mc.set("key"+i, "value"+i);
}
for(int i=0; i<100; i++){
System.out.println("get "+i+" value "+mc.get("key"+i));
}
System.out.println("-------------");
return m;
```