com.foxinmy.weixin4j.cache.MemoryCacheStorager Maven / Gradle / Ivy
package com.foxinmy.weixin4j.cache;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 用内存保存缓存对象(不推荐使用)
*
* @className MemoryCacheStorager
* @author jinyu([email protected])
* @date 2016年1月24日
* @since JDK 1.6
* @see
*/
public class MemoryCacheStorager implements
CacheStorager {
private final Map CONMAP;
public MemoryCacheStorager() {
this.CONMAP = new ConcurrentHashMap();
}
@Override
public T lookup(String key) {
T cache = this.CONMAP.get(key);
if (cache != null) {
if ((cache.getCreateTime() + cache.getExpires() - CUTMS) > System
.currentTimeMillis()) {
return cache;
}
}
return null;
}
@Override
public void caching(String key, T cache) {
this.CONMAP.put(key, cache);
}
@Override
public T evict(String key) {
return this.CONMAP.remove(key);
}
@Override
public void clear() {
this.CONMAP.clear();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy