首页>代码>spring项目整合ehcache和redis缓存实例>/ehcache/src/test/java/com/test/EhcacheTest.java
package com.test;


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

import com.web.dao.UserDao;

public class EhcacheTest {
	@Test
	public void testEhcache(){
		ApplicationContext ac = new ClassPathXmlApplicationContext("classpath*:applicationContext.xml");
		System.out.println(ac);
		UserDao userDao=ac.getBean(UserDao.class);
		System.out.println(userDao);
		System.out.println("第1次");
		long st=System.currentTimeMillis();
		System.out.println(userDao.get("1"));
		long end=System.currentTimeMillis();
		System.out.println("时间"+(end-st));
		
		System.out.println("第2次");
		long st1=System.currentTimeMillis();
		System.out.println(userDao.get("1"));
		long end1=System.currentTimeMillis();
		System.out.println("时间"+(end1-st1));
		
		System.out.println("第3次");
		long st2=System.currentTimeMillis();
		System.out.println(userDao.get("1"));
		long end2=System.currentTimeMillis();
		System.out.println("时间"+(end2-st2));
		
		System.out.println("第4次");
		long st3=System.currentTimeMillis();
		System.out.println(userDao.get("1"));
		long end3=System.currentTimeMillis();
		System.out.println("时间"+(end3-st3));
		
		System.out.println("第5次");
		long st4=System.currentTimeMillis();
		System.out.println(userDao.get("1"));
		long end4=System.currentTimeMillis();
		System.out.println("时间"+(end4-st4));
		
		System.out.println("第6次");
		long st5=System.currentTimeMillis();
		System.out.println(userDao.get("1"));
		long end5=System.currentTimeMillis();
		System.out.println("时间"+(end5-st5));
	}
}
最近下载更多
yinyun1985  LV14 2022年6月14日
and123456  LV11 2022年4月5日
xiaot99  LV7 2021年12月25日
java_php  LV11 2021年9月2日
xhmpmail  LV17 2021年2月24日
goowel  LV1 2020年11月18日
jammes  LV3 2020年6月8日
longyin2018  LV14 2019年11月18日
fei6549  LV10 2019年9月24日
start111  LV9 2019年8月12日
最近浏览更多
hbsoft2008  LV16 2023年7月24日
yinyun1985  LV14 2022年6月14日
and123456  LV11 2022年4月5日
JoyKinG  LV19 2022年2月23日
xiaot99  LV7 2021年12月25日
lvhaowen  LV20 2021年11月5日
chendaochao 2021年7月20日
暂无贡献等级
huangxiaoke20  LV17 2021年7月7日
denliv_hui  LV13 2021年6月21日
xhmpmail  LV17 2021年2月24日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友