K
- the most general type of keys this writer can write; for example Object
if any
key is acceptableV
- the most general type of values this write can write; for example Object
if
any value is acceptable@ThreadSafe public interface CacheWriter<K,V>
Modifier and Type | Method and Description |
---|---|
void |
delete(K key,
V value,
RemovalCause cause)
Deletes the value corresponding to the
key from the external resource. |
static <K,V> CacheWriter<K,V> |
disabledWriter()
Returns a writer that does nothing.
|
void |
write(K key,
V value)
Writes the value corresponding to the
key to the external resource. |
void write(@Nonnull K key, @Nonnull V value)
key
to the external resource. The cache will
communicate a write when an entry in the cache is inserted or updated explicitly. The implicit
creation of an entry due to being loaded when absent is not communicated.key
- the non-null key whose value should be writtenvalue
- the value associated with key
that should be writtenRuntimeException
- or Error, in which case the mapping is unchangedvoid delete(@Nonnull K key, @Nullable V value, @Nonnull RemovalCause cause)
key
from the external resource. The cache will
communicate a delete when the entry is explicitly removed or evicted.key
- the non-null key whose value was removedvalue
- the value associated with key
, or null
if collectedcause
- the reason for which the entry was removedRuntimeException
- or Error, in which case the mapping is unchanged@Nonnull static <K,V> CacheWriter<K,V> disabledWriter()
K
- the type of keysV
- the type of values