T
- the type this store puts/getspublic interface KeyValueStore<T>
Any synchronous calls to this API that fail exceptionally will throw a RuntimeException wrapping the original exception.
Asynchronous calls to this API that fail exceptionally will return their future completed exceptionally with the original exception.
It is up to the client to handle failures (in the form of unchecked exceptions) resulting from calls to this interface. This is particularly important in the case of asynchronous calls as the backing implementation may be overwhelmed depending on the rate in which case the user must implement their own retry logic to handle the futures that have completed exceptionally (in any case where it is not safe to ignore them).
Modifier and Type | Method and Description |
---|---|
void |
delete(String key,
String context) |
CompletableFuture<Void> |
deleteAsync(String key,
String context) |
Map<String,T> |
enumerateContext(String context) |
CompletableFuture<Map<String,T>> |
enumerateContextAsync(String context) |
Optional<T> |
get(String key,
String context) |
CompletableFuture<Optional<T>> |
getAsync(String key,
String context) |
Optional<Optional<T>> |
getIfStale(String key,
String context,
long timestamp) |
CompletableFuture<Optional<Optional<T>>> |
getIfStaleAsync(String key,
String context,
long timestamp) |
OptionalLong |
getLastUpdated(String key,
String context) |
CompletableFuture<OptionalLong> |
getLastUpdatedAsync(String key,
String context) |
String |
getName() |
long |
put(String key,
T value,
String context) |
long |
put(String key,
T value,
String context,
Integer ttlInSeconds)
Put a value with a suggested time-to-live after which the value should be expired and removed from the store.
|
CompletableFuture<Long> |
putAsync(String key,
T value,
String context) |
CompletableFuture<Long> |
putAsync(String key,
T value,
String context,
Integer ttlInSeconds)
Put a value with a suggested time-to-live after which the value should be expired and removed from the store.
|
void |
truncateContext(String context)
Remove all records for a given context.
|
CompletableFuture<Void> |
truncateContextAsync(String context)
Remove all records for a given context.
|
long put(String key, T value, String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)long put(String key, T value, String context, Integer ttlInSeconds)
Records are expired on a best effort basis and depending on the implementation it is possible to get an expired record.
context
- a context used to differentiate between keys with the same name (forms a compound key)ttlInSeconds
- the time to live in seconds for this key or no ttl if nullOptional<T> get(String key, String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)Optional<Optional<T>> getIfStale(String key, String context, long timestamp)
context
- a context used to differentiate between keys with the same name (forms a compound key)timestamp
- the timestamp of the last known state such that if an record with a more recent timestamp is
found the provided timestamp will be considered stale and the new record will be returnedOptionalLong getLastUpdated(String key, String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)Map<String,T> enumerateContext(String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)void delete(String key, String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)void truncateContext(String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)CompletableFuture<Long> putAsync(String key, T value, String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)CompletableFuture<Long> putAsync(String key, T value, String context, Integer ttlInSeconds)
Records are expired on a best effort basis and depending on the implementation it is possible to get an expired record.
context
- a context used to differentiate between keys with the same name (forms a compound key)ttlInSeconds
- the time to live in seconds for this key or no ttl if nullCompletableFuture<Optional<T>> getAsync(String key, String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)CompletableFuture<Optional<Optional<T>>> getIfStaleAsync(String key, String context, long timestamp)
context
- a context used to differentiate between keys with the same name (forms a compound key)timestamp
- the timestamp of the last known state such that if an record with a more recent timestamp is
found the provided timestamp will be considered stale and the new record will be returnedCompletableFuture<OptionalLong> getLastUpdatedAsync(String key, String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)String getName()
CompletableFuture<Map<String,T>> enumerateContextAsync(String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)CompletableFuture<Void> deleteAsync(String key, String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)CompletableFuture<Void> truncateContextAsync(String context)
context
- a context used to differentiate between keys with the same name (forms a compound key)Copyright © 2020. All rights reserved.