Package freemarker.cache
Class SoftCacheStorage
- java.lang.Object
-
- freemarker.cache.SoftCacheStorage
-
- All Implemented Interfaces:
CacheStorage,CacheStorageWithGetSize,ConcurrentCacheStorage
public class SoftCacheStorage extends Object implements ConcurrentCacheStorage, CacheStorageWithGetSize
Soft cache storage is a cache storage that usesSoftReferenceobjects 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's thread-safe in that case.
-
-
Constructor Summary
Constructors Constructor Description SoftCacheStorage()SoftCacheStorage(Map backingMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Objectget(Object key)intgetSize()Returns a close approximation of the number of cache entries.booleanisConcurrent()Returns true if this instance of cache storage is concurrently accessible from multiple threads without synchronization.voidput(Object key, Object value)voidremove(Object key)
-
-
-
Constructor Detail
-
SoftCacheStorage
public SoftCacheStorage()
-
SoftCacheStorage
public SoftCacheStorage(Map backingMap)
-
-
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)
- Specified by:
getin interfaceCacheStorage
-
put
public void put(Object key, Object value)
- Specified by:
putin interfaceCacheStorage
-
remove
public void remove(Object key)
- Specified by:
removein interfaceCacheStorage
-
clear
public void clear()
- Specified by:
clearin interfaceCacheStorage
-
getSize
public int getSize()
Returns a close approximation of the number of cache entries.- Specified by:
getSizein interfaceCacheStorageWithGetSize- Since:
- 2.3.21
-
-