public class BaseStringStringKeyValueStore<K,V> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Function<String,K> |
keyObjectConverter |
protected Function<K,String> |
keySerializer |
protected KeyValueStore<String,String> |
store
Store that does the actual writing to DB (likely).
|
protected Function<String,V> |
valueObjectConverter |
protected Function<V,String> |
valueSerializer |
| Constructor and Description |
|---|
BaseStringStringKeyValueStore(KeyValueStore<String,String> store) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the store.
|
boolean |
isClosed() |
boolean |
isOpen() |
V |
load(K key)
Get a value from the key value store.
|
KeyValueIterable<K,V> |
loadAll()
Load all of the key / values from the store.
|
Map<K,V> |
loadAllByKeys(Collection<K> keys) |
Collection<K> |
loadAllKeys() |
void |
put(K key,
V value)
Put a value in the key/value store.
|
void |
putAll(Map<K,V> values)
Put all of these values in the key value store.
|
void |
remove(K key)
Remove a key from the store.
|
void |
removeAll(Iterable<K> keys)
Remove all of these values from the key value store.
|
KeyValueIterable<K,V> |
search(K startKey)
Search for a key in the key / value store.
|
protected K |
toKeyObject(String key)
Convert a binary array to a String.
|
protected String |
toKeyString(K key)
Convert a String key to bytes.
|
protected V |
toValueObject(String value)
Use serializer to read this byte array as an object.
|
protected String |
toValueString(V v)
Converts an object to a byte array.
|
protected final KeyValueStore<String,String> store
public BaseStringStringKeyValueStore(KeyValueStore<String,String> store)
public void remove(K key)
key - public KeyValueIterable<K,V> search(K startKey)
startKey - public KeyValueIterable<K,V> loadAll()
public Collection<K> loadAllKeys()
public Map<K,V> loadAllByKeys(Collection<K> keys)
public void close()
protected K toKeyObject(String key)
key - keyprotected V toValueObject(String value)
value - value readprotected String toValueString(V v)
v - object to convertprotected String toKeyString(K key)
key - key to convertpublic void put(K key, V value)
key - keyvalue - valuepublic void putAll(Map<K,V> values)
values - valuespublic void removeAll(Iterable<K> keys)
keys - public boolean isOpen()
public boolean isClosed()
Copyright © 2014. All Rights Reserved.