com.clickntap.tool.cache.MemoryCacheManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of click_framework Show documentation
Show all versions of click_framework Show documentation
Java Framework based on Spring Framework, Freemarker and Simplicity
The newest version!
package com.clickntap.tool.cache;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class MemoryCacheManager implements CacheManager {
private HashMap caches;
public MemoryCacheManager() {
caches = new HashMap();
}
public Cache getCache(String cacheName, int maxSize) throws Exception {
synchronized (caches) {
if (!caches.containsKey(cacheName))
caches.put(cacheName, new MemoryCache());
return caches.get(cacheName);
}
}
public boolean containsCache(String cacheName) {
return true;
}
public void reset() {
synchronized (caches) {
caches = new HashMap();
}
}
public List getCacheNames() throws Exception {
synchronized (caches) {
List names = new ArrayList();
names.addAll(caches.keySet());
return names;
}
}
}