Computes the value for a given key k
that is missing from the cache.
Computes the value for a given key k
that is missing from the cache.
Note: This function will be called during class instantiation if the parent cache has already been started. Implementations should ensure that anything they depend on is already available, for example, as a constructor parameter or through a separate singleton implementation. Don't use values that are defined in the class itself as they would only be available after this base class has been initialized.
- cache key which value needs to be computed
- the value for the given key
The parent this cache is derived from.
The parent this cache is derived from.
Transforms a key value pair from the parent cache into a collection of key value pairs for this cache.
Transforms a key value pair from the parent cache into a collection of key value pairs for this cache.
- key of the parent cache
- value of the parent cache
- key,value pairs for this cache
Updates the cache with the proivided objects
and notifies all registered AsyncCacheEventHandler
s for cache miss for each of those objects.
Updates the cache with the proivided objects
and notifies all registered AsyncCacheEventHandler
s for cache miss for each of those objects.
View this cache as an immutable Map.
View this cache as an immutable Map. The returned Map is a snapshot of the cache, i.e. any changes to the cache, both incremental and bulk-reloads, are not reflected in the returned Map.
Peek if the given key is cached, resolved and present or not.
Peek if the given key is cached, resolved and present or not. If it is, it returns a Some of the value, otherwise None. This works by flattening down the return value of peek. This method does not trigger a remote call if the given key is not cached already.
Throws exception if the cache is not started, otherwise it will return the cached value for the provided key
.
Throws exception if the cache is not started, otherwise it will return the cached value for the provided key
.
If the cache doesn't contain the value for the key onCacheMiss
will be called, value will be cached and all registered AsyncCacheEventHandler
s will be notified.
Test if the cache has been started.
Test if the cache has been started.
Block for the result if the parent has a SYNC init strategy.
Block for the result if the parent has a SYNC init strategy. A bit of a hack, since we don't have API access to the parent's config.
Notifies all registered AsyncCacheEventHandler
's for a cache miss for the provided
key
.
Notifies all registered AsyncCacheEventHandler
's for a cache miss for the provided
key
.
- cache key
- cache value
Notifies all registered AsyncCacheEventHandler
's that provided
cache
was reloaded.
Notifies all registered AsyncCacheEventHandler
's that provided
cache
was reloaded.
- cache that was reloaded
Defines callback for cache miss.
Defines callback for cache miss.
- key for which we have a cache miss
- value for which we have a cache miss
Defines callback for cache reload.
Defines callback for cache reload.
- the cache that was reloaded
Peek if the given key is already cached or not.
Peek if the given key is already cached or not. If it is, it returns a Some of cached Future, otherwise None. This method does not trigger a remote call if the given key is not cached already.
Loads the content of this cache from its parent, if the parent is started.
Loads the content of this cache from its parent, if the parent is started. Register itself for parent cache change notifications.
This method should be called only once, when the cache is ready to receive notifications. Subsequent calls to this method are of no effect.
this cache ready to receive notifications from its parent
Register an AsyncCacheEventHandler
to be notified for cache events.
Register an AsyncCacheEventHandler
to be notified for cache events.
- the handler to be notified for cache events
Replaces the cache with the proivided objects
and notifies all registered AsyncCacheEventHandler
s for cache reload.
Replaces the cache with the proivided objects
and notifies all registered AsyncCacheEventHandler
s for cache reload.
Stop the cache from loading.
Stop the cache from loading.
Starts the loading of the cache.
Starts the loading of the cache.
An implementation of the
DerivedAsyncCacheBase
where all transformations are synchronous and return an Iterable of transformed key/value pairs for each key/value pair of the parent/source cache.- key type of the parent cache
- value type of the parent cache
- key type of this cache
- value type of this cache