public class ResourceCacheImpl extends java.lang.Object implements ResourceCache
resource.manager.cache.size
property (identified by the
RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE
constant). This property get be set to 0
or less for
a greedy, unbounded cache (the behavior from pre-v1.5).Modifier and Type | Class and Description |
---|---|
private static class |
ResourceCacheImpl.LRUMap<K,V>
A simple LRU Map based on
LinkedHashSet . |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.Object,Resource> |
cache
Cache storage, assumed to be thread-safe.
|
protected org.slf4j.Logger |
log |
protected RuntimeServices |
rsvc
Runtime services, generally initialized by the
initialize() method. |
Constructor and Description |
---|
ResourceCacheImpl() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the resources from this cache.
|
java.util.Iterator<java.lang.Object> |
enumerateKeys()
returns an Iterator of Keys in the cache.
|
Resource |
get(java.lang.Object key)
retrieves a Resource from the
cache
|
void |
initialize(RuntimeServices rs)
initializes the ResourceCache.
|
Resource |
put(java.lang.Object key,
Resource value)
stores a Resource in the cache
|
Resource |
remove(java.lang.Object key)
removes a Resource from the cache
|
protected java.util.Map<java.lang.Object,Resource> cache
protected RuntimeServices rsvc
initialize()
method.protected org.slf4j.Logger log
public void initialize(RuntimeServices rs)
ResourceCache
initialize
in interface ResourceCache
rs
- RuntimeServices to use for logging, etcResourceCache.initialize(org.apache.velocity.runtime.RuntimeServices)
public Resource get(java.lang.Object key)
ResourceCache
get
in interface ResourceCache
key
- key for Resource to be retrievedResourceCache.get(java.lang.Object)
public Resource put(java.lang.Object key, Resource value)
ResourceCache
put
in interface ResourceCache
key
- key to associate with the Resourcevalue
- Resource to be storedResourceCache.put(java.lang.Object, org.apache.velocity.runtime.resource.Resource)
public Resource remove(java.lang.Object key)
ResourceCache
remove
in interface ResourceCache
key
- resource to be removedResourceCache.remove(java.lang.Object)
public void clear()
ResourceCache
clear
in interface ResourceCache
ResourceCache.clear()
public java.util.Iterator<java.lang.Object> enumerateKeys()
ResourceCache
enumerateKeys
in interface ResourceCache
ResourceCache.enumerateKeys()