首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

自个儿编写泛型通用 Ehcache入门

2012-12-24 
自己编写泛型通用 Ehcache入门今天周末在家,无聊中看了下Ehcache,把我的Hello world 发表出了,呵呵:1.下载

自己编写泛型通用 Ehcache入门
今天周末在家,无聊中看了下Ehcache,把我的Hello world 发表出了,呵呵:
1.下载Ehcache包
   [url]http://nchc.dl.sourceforge.net/project/ehcache/ehcache/ehcache-2.4.2/ehcache-2.4.2-distribution.tar.gz
[/url]

2.ECLIPSE 创建java工程
(见附件)

GeneralCacheLoader.java
3.主要类

package com.sm.test;/** * 测试类 * @author Share Mu * */public class PersonEhcacheTest {public static void main(String[] args){PersonDataProviderImpl pdp = new PersonDataProviderImpl();GeneralCacheLoader<Person> pelps = new GeneralCacheLoader<Person>("mypersoncache",pdp);long c1 = System.currentTimeMillis();Person p = pelps.load("88");long c2 = System.currentTimeMillis();System.out.print("耗时"+(c2-c1));if(p==null){System.out.println("没发现....");}else{System.out.println("发现了...."+p.getName()+"--"+p.getCode());}long c3 = System.currentTimeMillis();p = pelps.load("88");long c4 = System.currentTimeMillis();System.out.print("耗时"+(c4-c3));if(p==null){System.out.println("没发现....");}else{System.out.println("发现了...."+p.getName()+"--"+p.getCode());}}}

热点排行