您的位置:首页 > 数据库 > Memcache

memcache与spring集成 实例

2012-08-07 10:35 295 查看
学习了memcache,这是个好东西,分享一下自己的小实例,也方便以后查找使用

一、前期准备

1)  下载memcached服务端memcached-1.2.6-win32-bin.zip,地址:http:
//code.jellycan.com/memcached/


TestMemcache.java测试类 用的是junit4

package com.pis.memcache;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.danga.MemCached.MemCachedClient;

public class TestMemcache {
MemCachedClient memCachedClient;
@Before
public void beforeTest(){

ApplicationContext atx = new ClassPathXmlApplicationContext("/spring/spring-memcache.xml");
memCachedClient = (MemCachedClient)atx.getBean("memCachedClient");
}

@Test
public void TestMem(){
memCachedClient.set("name", "han");

System.out.println(memCachedClient.get("name"));
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: