Class CacheAndReuseStrategy<T extends FeatureInput>
Object
org.anchoranalysis.feature.session.replace.CacheAndReuseStrategy<T>
- Type Parameters:
T- feature-input type
- All Implemented Interfaces:
ReplaceStrategy<T>
public class CacheAndReuseStrategy<T extends FeatureInput> extends Object implements ReplaceStrategy<T>
Reuse an existing
FeatureCalculationInput, as stored in a least-recently used cache, and
without invalidating it.
If no existing input is already stored, create a new one.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description CacheAndReuseStrategy(CacheCreator cacheCreator)Create with a particularCacheCreator. -
Method Summary
Modifier and Type Method Description FeatureCalculationInput<T>createOrReuse(T input)Find or create aFeatureCalculationInputto associate withinput.org.anchoranalysis.core.cache.LRUCache<T,FeatureCalculationInput<T>>getCache()The cache mapping a particular input to a correspondingFeatureCalculationInput.
-
Constructor Details
-
CacheAndReuseStrategy
Create with a particularCacheCreator.- Parameters:
cacheCreator- the cache-creator.
-
-
Method Details
-
createOrReuse
public FeatureCalculationInput<T> createOrReuse(T input) throws org.anchoranalysis.core.exception.OperationFailedExceptionDescription copied from interface:ReplaceStrategyFind or create aFeatureCalculationInputto associate withinput.- Specified by:
createOrReusein interfaceReplaceStrategy<T extends FeatureInput>- Parameters:
input- the input that aFeatureCalculationInputwill be associated with.- Returns:
- the
FeatureCalculationInput, either newly created, or reused from a previous call. - Throws:
org.anchoranalysis.core.exception.OperationFailedException- if an error-state emerge
-
getCache
The cache mapping a particular input to a correspondingFeatureCalculationInput.
-