freemarker.cache
public class: SoftCacheStorage [javadoc |
source]
java.lang.Object
freemarker.cache.SoftCacheStorage
All Implemented Interfaces:
ConcurrentCacheStorage
Soft cache storage is a cache storage that uses
SoftReference
objects to hold the objects it was passed, therefore allows the garbage
collector to purge the cache when it determines that it wants to free up
memory.
This class is thread-safe to the extent that its underlying map is. The
default implementation uses a concurrent map on Java 5 and above, so it is
thread-safe in that case.
- author:
Attila
- Szegedi
- version:
$
- Id: SoftCacheStorage.java,v 1.4 2003/09/22 20:47:03 ddekany Exp $
Method from freemarker.cache.SoftCacheStorage Detail: |
public void clear() {
map.clear();
processQueue();
}
|
public Object get(Object key) {
processQueue();
Reference ref = (Reference)map.get(key);
return ref == null ? null : ref.get();
}
|
public boolean isConcurrent() {
return concurrent;
}
|
public void put(Object key,
Object value) {
processQueue();
map.put(key, new SoftValueReference(key, value, queue));
}
|
public void remove(Object key) {
processQueue();
map.remove(key);
}
|