Class CacheAndReuseStrategy<T extends FeatureInput>
Object
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
ConstructorsConstructorDescriptionCacheAndReuseStrategy
(CacheCreator cacheCreator) Create with a particularCacheCreator
. -
Method Summary
Modifier and TypeMethodDescriptioncreateOrReuse
(T input) Find or create aFeatureCalculationInput
to associate withinput
.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
Description copied from interface:ReplaceStrategy
Find or create aFeatureCalculationInput
to associate withinput
.- Specified by:
createOrReuse
in interfaceReplaceStrategy<T extends FeatureInput>
- Parameters:
input
- the input that aFeatureCalculationInput
will be associated with.- Returns:
- the
FeatureCalculationInput
, either newly created, or reused from a previous call. - Throws:
OperationFailedException
- if an error-state emerge
-
getCache
The cache mapping a particular input to a correspondingFeatureCalculationInput
.
-