Class ResourceCacheImpl
java.lang.Object
org.apache.velocity.runtime.resource.ResourceCacheImpl
- All Implemented Interfaces:
ResourceCache
Default implementation of the resource cache for the default
ResourceManager. The cache uses a least recently used (LRU)
algorithm, with a maximum size specified via the
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).- Version:
- $Id$
- Author:
- Geir Magnusson Jr., Daniel Rall
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all of the resources from this cache.returns an Iterator of Keys in the cache.retrieves a Resource from the cachevoid
initializes the ResourceCache.stores a Resource in the cacheremoves a Resource from the cache
-
Field Details
-
cache
Cache storage, assumed to be thread-safe. -
rsvc
Runtime services, generally initialized by theinitialize()
method. -
log
protected org.slf4j.Logger log
-
-
Constructor Details
-
ResourceCacheImpl
public ResourceCacheImpl()
-
-
Method Details
-
initialize
Description copied from interface:ResourceCache
initializes the ResourceCache. Will be called before any utilization- Specified by:
initialize
in interfaceResourceCache
- Parameters:
rs
- RuntimeServices to use for logging, etc- See Also:
-
get
Description copied from interface:ResourceCache
retrieves a Resource from the cache- Specified by:
get
in interfaceResourceCache
- Parameters:
key
- key for Resource to be retrieved- Returns:
- Resource specified or null if not found
- See Also:
-
put
Description copied from interface:ResourceCache
stores a Resource in the cache- Specified by:
put
in interfaceResourceCache
- Parameters:
key
- key to associate with the Resourcevalue
- Resource to be stored- Returns:
- existing Resource stored under this key, or null if none
- See Also:
-
remove
Description copied from interface:ResourceCache
removes a Resource from the cache- Specified by:
remove
in interfaceResourceCache
- Parameters:
key
- resource to be removed- Returns:
- stored under key
- See Also:
-
clear
public void clear()Description copied from interface:ResourceCache
Removes all of the resources from this cache. The cache will be empty after this call returns.- Specified by:
clear
in interfaceResourceCache
- Since:
- 2.0
- See Also:
-
enumerateKeys
Description copied from interface:ResourceCache
returns an Iterator of Keys in the cache.- Specified by:
enumerateKeys
in interfaceResourceCache
- Returns:
- An Iterator of Keys in the cache.
- See Also:
-