Package io.rtr.alchemy.caching
Class CachingContext
java.lang.Object
io.rtr.alchemy.caching.CachingContext
- All Implemented Interfaces:
Closeable,AutoCloseable
A context object that allows you to interact safely with the cache, preventing multiple calls to
invalidate from triggering redundant cache reloads and allowing the user the option to invalidate
the cache asynchronously
-
Constructor Summary
ConstructorsConstructorDescriptionCachingContext(ExperimentsCache cache, Experiment.BuilderFactory builderFactory) CachingContext(ExperimentsCache cache, Experiment.BuilderFactory builderFactory, ExecutorService executorService) -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether any experiments are stalebooleancheckIfStale(String experimentName) Checks whether a given experiment is stalevoidclose()voidUpdates the cache with a recently deleted experimentvoidinvalidate(String experimentName, boolean async) Forces cache to reload a specific experiment from storagevoidinvalidateAll(boolean async) Forces cache to reload all data from storagevoidupdate(Experiment experiment) Updates the cache with a newly loaded experiment
-
Constructor Details
-
CachingContext
public CachingContext(ExperimentsCache cache, Experiment.BuilderFactory builderFactory, ExecutorService executorService) -
CachingContext
-
-
Method Details
-
invalidateAll
public void invalidateAll(boolean async) Forces cache to reload all data from storage -
invalidate
Forces cache to reload a specific experiment from storage -
update
Updates the cache with a newly loaded experiment -
delete
Updates the cache with a recently deleted experiment -
checkIfAnyStale
public boolean checkIfAnyStale()Checks whether any experiments are stale -
checkIfStale
Checks whether a given experiment is stale -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-