com.astamuse.asta4d.util.MemorySafeResourceCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of asta4d-core Show documentation
Show all versions of asta4d-core Show documentation
core functionalities of asta4d framework, including template and snippt implemention
package com.astamuse.asta4d.util;
import java.lang.ref.SoftReference;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* We want to cache the result of not found resources but a potential DDOS attack can be performed against this wish. Thus we cache the not
* found results in a SoftRreferenced map.
*
* @author e-ryu
*
* @param
* @param
*/
public class MemorySafeResourceCache {
public static class ResouceHolder {
private T resource;
ResouceHolder(T _res) {
resource = _res;
}
public T get() {
return resource;
}
public boolean exists() {
return resource != null;
}
}
private Map> existingResourceMap;
private SoftReference