Package net.sf.basedb.util.listable
Class TransformCache
java.lang.Object
net.sf.basedb.util.listable.TransformCache
public class TransformCache extends Object
A simple cache implementation for holding the result of source item to target item transformation.
- Since:
- 3.16
- Author:
- nicklas
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
TransformCache.CacheEntry
static class
TransformCache.CacheKey
-
Field Summary
Fields Modifier and Type Field Description private Map<TransformCache.CacheKey,TransformCache.CacheEntry>
cache
private long
nextCleanup
private long
timeoutInMillis
-
Constructor Summary
Constructors Constructor Description TransformCache(int timeoutInMinutes)
Creates a new cache with the specified timeout. -
Method Summary
Modifier and Type Method Description (package private) void
clean()
Set<Integer>
get(TransformCache.CacheKey key)
Get a cached entry if.static TransformCache.CacheKey
getKey(String cacheRegion, Item sourceType, Item targetType, SyncFilter.SourceItemTransform transform, Set<Integer> sourceIds)
static TransformCache.CacheKey
getKey(Item sourceType, Item targetType, SyncFilter.SourceItemTransform transform, Set<Integer> sourceIds)
Get a key that is able to identify a given transformation.void
store(TransformCache.CacheKey key, Set<Integer> targetList)
Store a new entry into the cache.
-
Field Details
-
cache
-
timeoutInMillis
private final long timeoutInMillis -
nextCleanup
private long nextCleanup
-
-
Constructor Details
-
TransformCache
public TransformCache(int timeoutInMinutes)Creates a new cache with the specified timeout.
-
-
Method Details
-
getKey
public static TransformCache.CacheKey getKey(Item sourceType, Item targetType, SyncFilter.SourceItemTransform transform, Set<Integer> sourceIds)Get a key that is able to identify a given transformation. We need the source and target item types as well as the transformation direction and all source items ids. It is recommended that the sourceIds set is aSortedSet
. If not, a new sorted set is automatically created. -
getKey
public static TransformCache.CacheKey getKey(String cacheRegion, Item sourceType, Item targetType, SyncFilter.SourceItemTransform transform, Set<Integer> sourceIds) -
get
Get a cached entry if. Null is returned if there is no entry or if the existing entry is too old. -
store
Store a new entry into the cache. -
clean
void clean()
-