JAVA缓存的实现(2)(转自其他地方)
2017-02-07 10:37
183 查看
package lhm.hcy.guge.frameset.cache;
/**
* <p>Title: </p>
*
* <p>Description: 缓存DTO</p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author Deepblue 2008-11-11
* @version 1.0
*/
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 boolean isExpired() {
return expired;
}
public void setExpired(boolean b) {
expired = b;
}
}
//测试类,
class Test {
public static void main(String[] args) {
System.out.println(CacheManager.getSimpleFlag("alksd"));
// CacheManager.putCache("abc", new Cache());
// CacheManager.putCache("def", new Cache());
// CacheManager.putCache("ccc", new Cache());
// CacheManager.clearOnly("");
// Cache c = new Cache();
// for (int i = 0; i < 10; i++) {
// CacheManager.putCache("" + i, c);
// }
// CacheManager.putCache("aaaaaaaa", c);
// CacheManager.putCache("abchcy;alskd", c);
// CacheManager.putCache("cccccccc", c);
// CacheManager.putCache("abcoqiwhcy", c);
// System.out.println("删除前的大小:"+CacheManager.getCacheSize());
// CacheManager.getCacheAllkey();
// CacheManager.clearAll("aaaa");
// System.out.println("删除后的大小:"+CacheManager.getCacheSize());
// CacheManager.getCacheAllkey();
}
}
/**
* <p>Title: </p>
*
* <p>Description: 缓存DTO</p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author Deepblue 2008-11-11
* @version 1.0
*/
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 boolean isExpired() {
return expired;
}
public void setExpired(boolean b) {
expired = b;
}
}
//测试类,
class Test {
public static void main(String[] args) {
System.out.println(CacheManager.getSimpleFlag("alksd"));
// CacheManager.putCache("abc", new Cache());
// CacheManager.putCache("def", new Cache());
// CacheManager.putCache("ccc", new Cache());
// CacheManager.clearOnly("");
// Cache c = new Cache();
// for (int i = 0; i < 10; i++) {
// CacheManager.putCache("" + i, c);
// }
// CacheManager.putCache("aaaaaaaa", c);
// CacheManager.putCache("abchcy;alskd", c);
// CacheManager.putCache("cccccccc", c);
// CacheManager.putCache("abcoqiwhcy", c);
// System.out.println("删除前的大小:"+CacheManager.getCacheSize());
// CacheManager.getCacheAllkey();
// CacheManager.clearAll("aaaa");
// System.out.println("删除后的大小:"+CacheManager.getCacheSize());
// CacheManager.getCacheAllkey();
}
}
相关文章推荐
- JAVA缓存的实现(1)(转自其他地方)
- java 实现 一个账号只能在一个地方登陆,其他地方被下线
- JS弹出模式提示窗体,实现页面其他地方不可编辑效果
- JAVA缓存的实现
- Java双缓存实现
- java web filter实现浏览器不缓存页面
- java一个实现实例缓存的不可变类
- 用java动态代理类实现方法缓存
- JAVA缓存的实现(转载)
- 用JAVA实现缓存
- java中读写锁的实现及使用读写锁简单实现缓存系统的实例
- java实现缓存
- JAVA缓存的实现
- Java实现LRU(最近最少使用)缓存
- 从其他地方移来的Java面题,欢迎讨论……
- java缓存的简单实现
- JS弹出模式提示窗体,实现页面其他地方不可编辑效果
- JAVA缓存的实现
- 使用java5的注解和Sping/AspectJ的AOP 来实现Memcached的缓存
- Java实现简单的LRU缓存(A Simple LRU Cache in 5 lines)