com.clickntap.tool.cache.MemoryCache 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
package com.clickntap.tool.cache;
import java.io.Serializable;
public class MemoryCache implements Cache {
private MemoryLruMap memory;
public MemoryCache() {
memory = new MemoryLruMap(999999);
}
public Serializable get(Serializable key) throws Exception {
synchronized (memory) {
return memory.get(key);
}
}
public Serializable put(Serializable key, Serializable value) throws Exception {
if (contains(key))
return value;
synchronized (memory) {
return memory.put(key, value);
}
}
public void remove(Serializable key) throws Exception {
synchronized (memory) {
memory.remove(key);
}
}
public void removeAll() throws Exception {
synchronized (memory) {
memory.clear();
}
}
public boolean contains(Serializable key) throws Exception {
synchronized (memory) {
return memory.containsKey(key);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy