Package org.cache2k
Interface CacheEntry<K,V>
-
- All Superinterfaces:
DataAware<K,V>
- All Known Subinterfaces:
LoadExceptionInfo<K,V>
,MutableCacheEntry<K,V>
public interface CacheEntry<K,V> extends DataAware<K,V>
Object representing a cache entry. With the cache entry, it can be checked whether a mapping in the cache is present, even if the cache containsnull
or contains an exception. Entries can be retrieved byCache.peekEntry(Object)
orCache.getEntry(Object)
or via iterated viaCache.entries()
.After retrieved, the entry instance does not change its values, even if the value for its key is updated in the cache.
Design note: The cache is generally also aware of the time the object will be refreshed next or when it will expire. This is not exposed to applications by intention.
- Author:
- Jens Wilke
- See Also:
Cache.peekEntry(Object)
,Cache.getEntry(Object)
,Cache.entries()
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default @Nullable Throwable
getException()
The exception happened when the value was loaded and the exception could not be suppressed.@Nullable LoadExceptionInfo<K,V>
getExceptionInfo()
Detailed information of the latest exception from the loader.K
getKey()
Key associated with this entry.V
getValue()
Value of the entry.
-
-
-
Method Detail
-
getKey
K getKey()
Key associated with this entry.
-
getValue
V getValue()
Value of the entry. The value may benull
if permitted for this cache viaCache2kBuilder.permitNullValues(boolean)
. If the entry had a loader exception which is not suppressed, this exception will be propagated. This can be customized withCache2kBuilder.exceptionPropagator(ExceptionPropagator)
For usage within the
EntryProcessor
: If a loader is present and the entry is not yet loaded or expired, a load is triggered. See the details at:MutableCacheEntry.getValue()
- Throws:
CacheLoaderException
- if loading produced an exception
-
getException
@Nullable default @Nullable Throwable getException()
The exception happened when the value was loaded and the exception could not be suppressed.null
if no exception happened or it was suppressed. Ifnull
thengetValue()
returns a value and does not throw an exception.
-
getExceptionInfo
@Nullable @Nullable LoadExceptionInfo<K,V> getExceptionInfo()
Detailed information of the latest exception from the loader.null
if no exception happened or was suppressed. Ifnull
thengetValue()
returns a value and does not throw an exception.
-
-