
com.ajaxjs.util.cache.MemoryCacheManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ajaxjs-base Show documentation
Show all versions of ajaxjs-base Show documentation
A pure Java library that provides many tools, utils, and functions.
package com.ajaxjs.util.cache;
import java.util.concurrent.ConcurrentHashMap;
/**
* 基于虚拟机内存的cache管理器
*
*/
public class MemoryCacheManager extends ConcurrentHashMap> implements CacheManager {
private static final long serialVersionUID = -8273827743219735439L;
@Override
public Cache getCache(String name) {
@SuppressWarnings("unchecked")
Cache cache = (Cache) get(name);
if (cache == null) {
cache = new MemoryCache<>();
put(name, cache);
}
return cache;
}
@Override
public void destroy() {
while (!isEmpty())
clear();
}
@Override
public Cache getCache(String name, Class clz) {
@SuppressWarnings("unchecked")
Cache cache = (Cache) get(name);
if (cache == null) {
cache = new MemoryCache<>();
put(name, cache);
}
return cache;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy