V - the value typepublic abstract class AbstractStableReadExternalCache<V> extends AbstractExternalCache<V> implements StableReadExternalCache<V>
StableReadExternalCache instances.
Locking is provided to synchronise the local and remote caches. There are two locking strategies - a cache wide read-write lock and a per-key lock. The cache wide lock provides exclusion for multi-key operations such as removeAll and getBulk. The key lock provides locking for single key get and put whilst honouring the cache lock.
| Modifier and Type | Field and Description |
|---|---|
protected MetricsRecorder |
metricsRecorder |
lockTimeout, name| Modifier | Constructor and Description |
|---|---|
protected |
AbstractStableReadExternalCache(String name,
MetricsRecorder metricsRecorder,
Duration lockTimeout,
ExternalCacheExceptionListener externalCacheExceptionListener) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract Optional<V> |
directGet(String externalKey)
Performs a direct get operation against the external cache using the supplied external key.
|
protected abstract Map<String,Optional<V>> |
directGetBulk(Set<String> externalKeys)
Performs a direct bulk get operation against the external cache using the supplied external keys.
|
CompletionStage<Optional<V>> |
get(String internalKey)
Returns a value that is associated with a specified key.
|
CompletionStage<V> |
get(String internalKey,
Supplier<V> supplier)
Returns a value that may be associated with a specified key.
|
CompletionStage<Map<String,V>> |
getBulk(Function<Set<String>,Map<String,V>> factory,
Iterable<String> internalKeys)
Returns the values that are associated with the specified keys.
|
CompletionStage<Map<String,Optional<V>>> |
getBulk(Iterable<String> internalKeys)
Returns the values that are associated with the specified keys.
|
protected abstract V |
handleCreation(String internalKey,
V candidateValue)
Handles the creation of an entry, if required.
|
protected abstract boolean |
internalPut(String internalKey,
V value,
PutPolicy policy) |
protected abstract void |
internalRemove(Iterable<String> keys) |
protected abstract void |
internalRemoveAll() |
CompletionStage<Boolean> |
put(String internalKey,
V value,
PutPolicy policy)
Puts the value under the specified key using the specified policy.
|
CompletionStage<Void> |
remove(Iterable<String> keys)
Remove the entries with the specified keys.
|
CompletionStage<Void> |
removeAll()
Remove all entries in the cache.
|
ensureCacheContext, getLogger, getName, mapException, perform, performclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBulk, getBulkremoveprotected final MetricsRecorder metricsRecorder
protected AbstractStableReadExternalCache(String name, MetricsRecorder metricsRecorder, Duration lockTimeout, ExternalCacheExceptionListener externalCacheExceptionListener)
protected abstract void internalRemoveAll()
protected abstract V handleCreation(String internalKey, V candidateValue) throws ExecutionException, InterruptedException
internalKey - the internal key for the entry.candidateValue - the candidate value to add, if requiredExecutionExceptionInterruptedExceptionprotected abstract Optional<V> directGet(String externalKey)
protected abstract Map<String,Optional<V>> directGetBulk(Set<String> externalKeys)
public final CompletionStage<Optional<V>> get(String internalKey)
ExternalCacheget in interface ExternalCache<V>internalKey - the key to check.Optional which may contain the value associated with the key.public final CompletionStage<V> get(String internalKey, Supplier<V> supplier)
ExternalCacheNotes:
ExternalCache.getBulk(java.lang.String...).
When the supplier is called, callers may not assume that the value returned from the supplier is returned
by this method.
get in interface ExternalCache<V>internalKey - the key uniquely identifying the value to be retrievedsupplier - used to generate the value, if one does not exist already for the key. The supplier may not
return null.public final CompletionStage<Map<String,Optional<V>>> getBulk(Iterable<String> internalKeys)
ExternalCachepublic final CompletionStage<Map<String,V>> getBulk(Function<Set<String>,Map<String,V>> factory, Iterable<String> internalKeys)
ExternalCacheNotes:
ExternalCache.get(String, Supplier).
When the factory is called, callers may not assume that the values returned from the factory
is returned by this method.
getBulk in interface ExternalCache<V>factory - used to generate the values for the keys that do not have entries. The factory must return a
map containing a non-null entry for each supplied key.internalKeys - the keys to retrieveMap that is keyed on the keys specified. Each entry in the Map will have
the value associated with the key.public final CompletionStage<Boolean> put(String internalKey, V value, PutPolicy policy)
ExternalWriteOperationsUnbufferedput in interface ExternalWriteOperationsUnbuffered<V>internalKey - the key to put the data undervalue - the value to associate with the key.policy - the policy to applypublic final CompletionStage<Void> remove(Iterable<String> keys)
ExternalWriteOperationsUnbufferedremove in interface ExternalWriteOperationsUnbuffered<V>keys - the keys of the entries to remove.public final CompletionStage<Void> removeAll()
ExternalWriteOperationsUnbufferedremoveAll in interface ExternalWriteOperationsUnbuffered<V>Copyright © 2019 Atlassian. All rights reserved.