V - type of the related data.public interface SelfLoadingCache<V>
This facade queries the underlying CacheProvider
for the given key, if the related entry is null
or expired uses the given DataProvider to retrieve
the related data and populate the cache.
The assumption behind this interface is that the given key is able to uniquely identify the related data and therefore contains all the information needed to retrieve it.
If a given key is not present in the cache uses the given
DataProvider to retrieve the related data, if the
key is present but expired will be marked as still valid
and the DataProvider will be used to update the
related value.
| Modifier and Type | Method and Description |
|---|---|
static void |
disableAll(boolean disable)
Invoking this method with
true will disable all SelfLoadingCache
instances in the system. |
void |
disableThis(boolean disable)
Invoking this method with
true will disable this SelfLoadingCache
instance. |
void |
evict(CacheKey key)
Removes the given key from the underlying cache system
forcing to reload it the next time
get(CacheKey, DataProvider)
is invoked. |
V |
get(CacheKey key,
DataProvider<V> dataProvider)
Returns the value related to the given key.
|
V get(CacheKey key, DataProvider<V> dataProvider)
If the given key is not present in the cache or
the related entry is expired the given
DataProvider will be used to retrieve
the data to store into the cache.
key - the key to search for.dataProvider - the provider of the information to cache.null.void evict(CacheKey key)
get(CacheKey, DataProvider)
is invoked.key - key to be evicted.void disableThis(boolean disable)
true will disable this SelfLoadingCache
instance. All the caching will be skipped and all data will be loaded from the
DataProvider on each request.
This option should be used to debugging purposes only, using this option in production can be very dangerous.
Invoking this method with false will restore the caching process.
disable - tells if this SelfLoadingCache instance needs to stop
all caching operations.static void disableAll(boolean disable)
true will disable all SelfLoadingCache
instances in the system. All the caching will be skipped and all data will be
loaded from the DataProvider on each request.
This option should be used to debugging purposes only, using this option in production can be very dangerous.
Invoking this method with false will restore the caching process.
disable - tells if all SelfLoadingCache instances need to stop
all caching operations.Copyright © 2011–2020 Nerd4j. All rights reserved.