JAVA 缓存 1 Cache 类 2 CacheManager类 JAVA 缓存有两种: 一、文件缓存,是指把数据存储在磁盘上,可以XML 格式,也可以序列化文件DAT 格式还是其它文件格式
二、内存缓存,也就是实现一个类中静态Map,对这个Map 进行常规的增删查
其代码如下: JAVA 缓存 - Cache 类 public class Cache { private String key;//缓存ID private Object value;//缓存数据 private long timeOut;//更新时间 private boolean expired; //是否终止 public Cache() { super(); } public Cache(String key, Object value, long timeOut, boolean expired) { this
key = key; this
value = value; this
timeOut = timeOut; this
expired = expired; } public String getKey() { return key; } public long getTimeOut() { return timeOut; } public Object getValue() { return value; } public void setKey(String string) { key = string; } public void setTimeOut(long l) { timeOut = l; } public void setValue(Object object) { value = object; } public booleanisExpired() { re