public class RedisKeyValueState<K,V> extends Object implements KeyValueState<K,V>
A redis based implementation that persists the state in Redis.
| Modifier and Type | Field and Description |
|---|---|
static NavigableMap<byte[],byte[]> |
EMPTY_PENDING_COMMIT_MAP |
static int |
ITERATOR_CHUNK_SIZE |
| Constructor and Description |
|---|
RedisKeyValueState(String namespace) |
RedisKeyValueState(String namespace,
JedisClusterConfig jedisClusterConfig,
Serializer<K> keySerializer,
Serializer<V> valueSerializer) |
RedisKeyValueState(String namespace,
JedisPoolConfig poolConfig) |
RedisKeyValueState(String namespace,
JedisPoolConfig poolConfig,
Serializer<K> keySerializer,
Serializer<V> valueSerializer) |
RedisKeyValueState(String namespace,
RedisCommandsInstanceContainer container,
Serializer<K> keySerializer,
Serializer<V> valueSerializer) |
| Modifier and Type | Method and Description |
|---|---|
void |
commit()
Persist the current state.
|
void |
commit(long txid)
Commit a previously prepared transaction.
|
V |
delete(K key)
Deletes the value mapped to the key, if there is any.
|
V |
get(K key)
Returns the value mapped to the key.
|
V |
get(K key,
V defaultValue)
Returns the value mapped to the key or defaultValue if no mapping is found.
|
Iterator<Map.Entry<K,V>> |
iterator() |
void |
prepareCommit(long txid)
Invoked by the framework to prepare a transaction for commit.
|
void |
put(K key,
V value)
Maps the value with the key.
|
void |
rollback()
Rollback a prepared transaction to the previously committed state.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic static final int ITERATOR_CHUNK_SIZE
public static final NavigableMap<byte[],byte[]> EMPTY_PENDING_COMMIT_MAP
public RedisKeyValueState(String namespace)
public RedisKeyValueState(String namespace, JedisPoolConfig poolConfig)
public RedisKeyValueState(String namespace, JedisPoolConfig poolConfig, Serializer<K> keySerializer, Serializer<V> valueSerializer)
public RedisKeyValueState(String namespace, JedisClusterConfig jedisClusterConfig, Serializer<K> keySerializer, Serializer<V> valueSerializer)
public RedisKeyValueState(String namespace, RedisCommandsInstanceContainer container, Serializer<K> keySerializer, Serializer<V> valueSerializer)
public void put(K key, V value)
KeyValueStateMaps the value with the key.
put in interface KeyValueState<K,V>key - the keyvalue - the valuepublic V get(K key)
KeyValueStateReturns the value mapped to the key.
get in interface KeyValueState<K,V>key - the keypublic V get(K key, V defaultValue)
KeyValueStateReturns the value mapped to the key or defaultValue if no mapping is found.
get in interface KeyValueState<K,V>key - the keydefaultValue - the value to return if no mapping is foundpublic V delete(K key)
KeyValueStateDeletes the value mapped to the key, if there is any.
delete in interface KeyValueState<K,V>key - the keypublic void prepareCommit(long txid)
StateInvoked by the framework to prepare a transaction for commit. It should be possible to commit the prepared state later.
The same txid can be prepared again, but the next txid cannot be prepared when previous one is not yet committed.
prepareCommit in interface Statetxid - the transaction idpublic void commit(long txid)
StateCommit a previously prepared transaction. It should be possible to retrieve a committed state later.
public void commit()
StatePersist the current state. This is used when the component manages the state.
Copyright © 2021 The Apache Software Foundation. All rights reserved.