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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
clean()
Set<Integer>
get(TransformCache.CacheKey key)
Get a cached entry if.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 Detail
-
cache
private final Map<TransformCache.CacheKey,TransformCache.CacheEntry> cache
-
timeoutInMillis
private final long timeoutInMillis
-
nextCleanup
private long nextCleanup
-
-
Method Detail
-
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.
-
get
public Set<Integer> get(TransformCache.CacheKey key)
Get a cached entry if. Null is returned if there is no entry or if the existing entry is too old.
-
store
public void store(TransformCache.CacheKey key, Set<Integer> targetList)
Store a new entry into the cache.
-
clean
void clean()
-
-