Package freemarker.cache
Class SoftCacheStorage
- java.lang.Object
-
- freemarker.cache.SoftCacheStorage
-
- All Implemented Interfaces:
CacheStorage
,CacheStorageWithGetSize
,ConcurrentCacheStorage
public class SoftCacheStorage extends java.lang.Object implements ConcurrentCacheStorage, CacheStorageWithGetSize
Soft cache storage is a cache storage that usesSoftReference
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 parameterless constructor uses a thread-safe map since 2.3.24 or Java 5.
-
-
Constructor Summary
Constructors Constructor Description SoftCacheStorage()
Creates an instance that uses aConcurrentMap
internally.SoftCacheStorage(java.util.Map backingMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
java.lang.Object
get(java.lang.Object key)
int
getSize()
Returns a close approximation of the number of cache entries.boolean
isConcurrent()
Returns true if the underlying Map is aConcurrentMap
.void
put(java.lang.Object key, java.lang.Object value)
void
remove(java.lang.Object key)
-
-
-
Method Detail
-
isConcurrent
public boolean isConcurrent()
Returns true if the underlying Map is aConcurrentMap
.- Specified by:
isConcurrent
in interfaceConcurrentCacheStorage
- Returns:
- true if this instance of cache storage is concurrently accessible from multiple threads without synchronization.
-
get
public java.lang.Object get(java.lang.Object key)
- Specified by:
get
in interfaceCacheStorage
-
put
public void put(java.lang.Object key, java.lang.Object value)
- Specified by:
put
in interfaceCacheStorage
-
remove
public void remove(java.lang.Object key)
- Specified by:
remove
in interfaceCacheStorage
-
clear
public void clear()
- Specified by:
clear
in interfaceCacheStorage
-
getSize
public int getSize()
Returns a close approximation of the number of cache entries.- Specified by:
getSize
in interfaceCacheStorageWithGetSize
- Since:
- 2.3.21
-
-