public class MemKeyValueStore extends Object implements KeyValueStoreProvider
Modifier and Type | Field and Description |
---|---|
protected Map<String,byte[]> |
map |
protected Lock |
readLock |
protected Lock |
writeLock |
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)
Atomically sets the value associated to the key to the given value if the current value is the expected value.
|
byte[] |
get(String key)
Retrieves the value associated to the key.
|
void |
initialize(Map<String,String> properties)
Initializes this Key/Value store provider.
|
void |
put(String key,
byte[] value)
Sets the value associated to the key.
|
public MemKeyValueStore()
public void initialize(Map<String,String> properties)
KeyValueStoreProvider
initialize
in interface KeyValueStoreProvider
properties
- the store provide properties.public void close()
KeyValueStoreProvider
close
in interface KeyValueStoreProvider
public void clear()
KeyValueStoreProvider
clear
in interface KeyValueStoreProvider
protected static byte[] clone(byte[] value)
public void put(String key, byte[] value)
KeyValueStore
put
in interface KeyValueStore
key
- the keyvalue
- the value, which may be null
public byte[] get(String key)
KeyValueStore
get
in interface KeyValueStore
key
- the keynull
if there is no valuepublic boolean compareAndSet(String key, byte[] expected, byte[] value)
KeyValueStore
Note value comparison is done by value and not by reference.
compareAndSet
in interface KeyValueStore
key
- the keyexpected
- the expected value, which may be null
value
- the updated value, which may be null
true
if the value was updated, or false
if not (the expected value was not found)Copyright © 2017 Nuxeo. All rights reserved.