Package freemarker.cache
Class StrongCacheStorage
- java.lang.Object
-
- freemarker.cache.StrongCacheStorage
-
- All Implemented Interfaces:
CacheStorage,ConcurrentCacheStorage
public class StrongCacheStorage extends Object implements ConcurrentCacheStorage
Strong cache storage is a cache storage that simply wraps aMap. It holds a strong reference to all objects it was passed, therefore prevents the cache from being purged during garbage collection. 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.
-
-
Constructor Summary
Constructors Constructor Description StrongCacheStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all values from this cacheObjectget(Object key)Retrieve a cached value associated with a keybooleanisConcurrent()Returns true if this instance of cache storage is concurrently accessible from multiple threads without synchronization.voidput(Object key, Object value)Associates a key with a cached valuevoidremove(Object key)Removes the value associated with a key, if it exists.
-
-
-
Method Detail
-
isConcurrent
public boolean isConcurrent()
Description copied from interface:ConcurrentCacheStorageReturns true if this instance of cache storage is concurrently accessible from multiple threads without synchronization.- Specified by:
isConcurrentin interfaceConcurrentCacheStorage- Returns:
- true if this instance of cache storage is concurrently accessible from multiple threads without synchronization.
-
get
public Object get(Object key)
Description copied from interface:CacheStorageRetrieve a cached value associated with a key- Specified by:
getin interfaceCacheStorage- Parameters:
key- the key for retrieving an associated value- Returns:
- the cached value associated with the key, or null if no value is associated with the key.
-
put
public void put(Object key, Object value)
Description copied from interface:CacheStorageAssociates a key with a cached value- Specified by:
putin interfaceCacheStorage- Parameters:
key- the key to associate with a valuevalue- the value associated with the key.
-
remove
public void remove(Object key)
Description copied from interface:CacheStorageRemoves the value associated with a key, if it exists. If it doesn't exist, this method does nothing.- Specified by:
removein interfaceCacheStorage- Parameters:
key- the key whose associated value is removed from the cache.
-
clear
public void clear()
Description copied from interface:CacheStorageRemoves all values from this cache- Specified by:
clearin interfaceCacheStorage
-
-