public class MemKeyValueStore extends AbstractKeyValueStoreProvider
| Modifier and Type | Field and Description |
|---|---|
protected net.jodah.expiringmap.ExpiringMap<String,byte[]> |
map |
protected Lock |
writeLock |
name, UTF_8_DECODERS| Constructor and Description |
|---|
MemKeyValueStore() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the content of this Key/Value store provider.
|
protected static byte[] |
clone(byte[] value) |
void |
close()
Closes this Key/Value store provider.
|
boolean |
compareAndSet(String key,
byte[] expected,
byte[] value,
long ttl)
Atomically sets the value associated to the key to the given value, with the given TTL, if the current value is
the expected value.
|
protected void |
doSetTTL(String key,
long ttl) |
byte[] |
get(String key)
Retrieves the value associated to the key.
|
Stream<String> |
keyStream()
Returns a
Stream of the keys contained in this Key/Value store provider. |
Stream<String> |
keyStream(String prefix)
Returns a
Stream of the keys with the given prefix contained in this Key/Value store provider. |
void |
put(String key,
byte[] value,
long ttl)
Sets the value associated to the key, and a TTL.
|
boolean |
setTTL(String key,
long ttl)
Sets the TTL for an existing key.
|
addAndGet, bytesToLong, bytesToString, compareAndSet, compareAndSet, compareAndSet, get, getLong, getLongs, getString, getStrings, initialize, longToBytes, put, put, put, put, put, stringToBytes, toStringpublic MemKeyValueStore()
public Stream<String> keyStream()
KeyValueStoreProviderStream of the keys contained in this Key/Value store provider.
This operation may be slow and should only be used for management or debug purposes.
public Stream<String> keyStream(String prefix)
KeyValueStoreProviderStream of the keys with the given prefix contained in this Key/Value store provider.
This operation may be slow and should only be used for management or debug purposes.
public void close()
KeyValueStoreProviderpublic void clear()
KeyValueStoreProviderprotected static byte[] clone(byte[] value)
public void put(String key, byte[] value, long ttl)
KeyValueStorekey - the keyvalue - the value, which may be nullttl - the TTL, in seconds (0 for infinite)public byte[] get(String key)
KeyValueStorekey - the keynull if there is no valuepublic boolean setTTL(String key, long ttl)
KeyValueStorekey - the keyttl - the TTL, in seconds (0 for infinite)true if the TTL has been set, or false if the key does not existpublic boolean compareAndSet(String key, byte[] expected, byte[] value, long ttl)
KeyValueStoreNote value comparison is done by value and not by reference.
key - the keyexpected - the expected value, which may be nullvalue - the updated value, which may be nullttl - the TTL, in seconds (0 for infinite)true if the value was updated, or false if not (the expected value was not found)Copyright © 2019 Nuxeo. All rights reserved.