Package io.github.xanthic.cache.core
Class AbstractCache<K,V>
java.lang.Object
io.github.xanthic.cache.core.AbstractCache<K,V>
- Type Parameters:
K
- The type of keys that form the cacheV
- The type of values contained in the cache
- All Implemented Interfaces:
io.github.xanthic.cache.api.Cache<K,
V>
public abstract class AbstractCache<K,V>
extends Object
implements io.github.xanthic.cache.api.Cache<K,V>
Provides a common implementation of:
Cache.computeIfAbsent(Object, Function)
Cache.putIfAbsent(Object, Object)
Cache.merge(Object, Object, BiFunction)
Subclasses ought to synchronize on getLock()
for correctness.
Avoid this abstraction if the backing cache provider already provides an implementation for these methods.
Does not support null values.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeIfAbsent
(K key, @NotNull Function<K, V> computeFunc) computeIfPresent
(K key, @NotNull BiFunction<? super K, ? super V, ? extends V> computeFunc) protected @NotNull Object
getLock()
putIfAbsent
(K key, V value) boolean
boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.xanthic.cache.api.Cache
clear, forEach, get, getOrDefault, put, putAll, remove, size
-
Constructor Details
-
AbstractCache
public AbstractCache()
-
-
Method Details
-
computeIfAbsent
-
compute
-
computeIfPresent
-
putIfAbsent
-
merge
-
replace
-
replace
-
getLock
-