import net.sf.ehcache.Ehcache;
import org.springframework.beans.factory.annotation.Autowired;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import org.springframework.stereotype.Component;
/**
* User:
* Date: 13-2-21
* Time: 上午11:17
*/
@Component
public class EhCacheTool {
private static final String CACHE_NAME = "defaultEcarCache";
@Autowired
private Ehcache ehCache;
public void put(Object key, Object value) {
//initCache();
Element element = new Element(key, value);
ehCache.put(element);
}
public Object get(Object key) {
//initCache();
Element element = ehCache.get(key);
if(element == null) {
return null;
}
return element.getObjectValue();
}
/*private void initCache() {
cache = ehcacheManager.getCache(CACHE_NAME);
}*/
}
Ehcache
最新推荐文章于 2024-05-31 16:40:25 发布