Acquires the cache value of a given key.
Acquires the cache value of a given key.
A cache entry, like an exclusive lock, can only be acquired by one instance at a time, therefore if the
entry is still locked, this method throws an immediate IllegalStateException
.
If the entry is still found on disk, it will be re-used, given that the configuration's accept
method
returns true
. If the entry is not found or not accepted, a new value is produced by spawning the source
in its own future (using the configuration's executionContext
).
If the source naturally returns a future, use acquireWith
instead.
When the value is not used any more, the caller should invoke release
to make it possible for the entry
to be evicted when over capacity. Only a released entry can be re-acquired.
the key to look up
the source which is only used if the entry was not found or not accepted
the future value of the cache entry (this might result in an I/O exception for example)
Acquires the cache value of a given key.
Acquires the cache value of a given key.
This method is equivalent to acquire
but takes a source in the form of a future. See acquire
for
more details on the mechanism and requirements of this process.
the key to look up
the source which is only used if the entry was not found or not accepted
the future value of the cache entry (this might result in an I/O exception for example)
The context used by the cache to spawn future computations.
The context used by the cache to spawn future computations. This is directly taken from its configuration, and is provided here for clients to easily import it as an implicit value, e.g. to create its own futures.
Release a cache entry.
Release a cache entry. The caller must have acquired the entry for the given key, using
acquire
or acquireWith
. If the entry is not locked, this method will throw an IllegalStateException
.
Releasing the entry makes it possible to evict it from the cache if the cache capacity is exhausted.
the key to release
Reports the current statistics of the cache, which are number of entries, total size and age span.