Class PolicyCache
- java.lang.Object
-
- de.fraunhofer.iese.mydata.pmp.cache.PolicyCache
-
- All Implemented Interfaces:
IPolicyCache
public class PolicyCache extends Object implements IPolicyCache
Keeps a copy of a policy list- Author:
- feth
-
-
Constructor Summary
Constructors Constructor Description PolicyCache()
PolicyCache(java.util.function.Supplier<java.time.Instant> instantSupplier, String cachePath, java.time.Duration maxCacheAge)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Set<de.fraunhofer.iese.mydata.policy.Policy>>
getPolicies()
void
invalidate()
invalidates the cacheboolean
isValid()
boolean
updateCache(Set<de.fraunhofer.iese.mydata.policy.Policy> policies)
updates cache content and refreshes validation timevoid
validate()
refreshes validation time of the cache without changing its contents
-
-
-
Constructor Detail
-
PolicyCache
public PolicyCache()
-
PolicyCache
public PolicyCache(java.util.function.Supplier<java.time.Instant> instantSupplier, String cachePath, @Nullable java.time.Duration maxCacheAge)
-
-
Method Detail
-
getPolicies
public Optional<Set<de.fraunhofer.iese.mydata.policy.Policy>> getPolicies()
- Specified by:
getPolicies
in interfaceIPolicyCache
- Returns:
- the cached policies if cache is valid or else empty Optional
-
isValid
public boolean isValid()
- Specified by:
isValid
in interfaceIPolicyCache
- Returns:
- whether the cache is valid
-
invalidate
public void invalidate()
Description copied from interface:IPolicyCache
invalidates the cache- Specified by:
invalidate
in interfaceIPolicyCache
-
validate
public void validate()
Description copied from interface:IPolicyCache
refreshes validation time of the cache without changing its contents- Specified by:
validate
in interfaceIPolicyCache
-
updateCache
public boolean updateCache(Set<de.fraunhofer.iese.mydata.policy.Policy> policies)
Description copied from interface:IPolicyCache
updates cache content and refreshes validation time- Specified by:
updateCache
in interfaceIPolicyCache
- Returns:
- whether updating the cache succeeded
-
-