|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
K
- The type of the key being storedV
- The type of the value being storedpublic interface IStoreClient<K,V>
The user-facing interface to a sync store. Gives basic put/get/delete plus helper functions.
Method Summary | |
---|---|
void |
addStoreListener(IStoreListener<K> listener)
Add a listener that will be notified about changes to the given store. |
void |
delete(K key)
Delete the key by writing a null tombstone to the store obliterating any existing value stored for the key. |
void |
delete(K key,
IVersion version)
Delete the key by writing a null tombstone to the store using the provided IVersion . |
IClosableIterator<java.util.Map.Entry<K,Versioned<V>>> |
entries()
Get an iterator that will get all the entries in the store. |
Versioned<V> |
get(K key)
Get the versioned value associated with the given key. |
Versioned<V> |
get(K key,
Versioned<V> defaultValue)
Get the versioned value associated with the given key or the defaultValue if no value is associated with the key. |
V |
getValue(K key)
Get the value associated with the given key or null if there is no value associated with this key. |
V |
getValue(K key,
V defaultValue)
Get the value associated with the given key or defaultValue if there is no value associated with the key. |
IVersion |
put(K key,
V value)
Associated the given value to the key, clobbering any existing values stored for the key. |
IVersion |
put(K key,
Versioned<V> versioned)
Put the given Versioned value into the store for the given key if the version is greater to or concurrent with existing values. |
boolean |
putIfNotObsolete(K key,
Versioned<V> versioned)
Put the versioned value to the key, ignoring any ObsoleteVersionException that may be thrown |
Method Detail |
---|
V getValue(K key) throws SyncException
key
- The key
SyncException
V getValue(K key, V defaultValue) throws SyncException
key
- The key for which to fetch the associated valuedefaultValue
- A value to return if there is no value associated
with this key
SyncException
Versioned<V> get(K key) throws SyncException
Versioned
returned
can have a null value (i.e. can be null
if the key is not present.
key
- The key for which to fetch the value.
SyncException
Versioned<V> get(K key, Versioned<V> defaultValue) throws SyncException
key
- The key for which to fetch the value.
SyncException
IClosableIterator<java.util.Map.Entry<K,Versioned<V>>> entries() throws SyncException
IClosableIterator
when you are
finished with it or there may be resource leaks. An example of how you
should use this iterator to ensure that it is closed even if there are
exceptions follows:
IClosableIterator iter = store.entries();
try {
// do your iteration
} finally {
iter.close();
}
Another important caveat is that because IClosableIterator
extends Iterator
, there is no checked exception declared in
Iterator.next()
. Because of this, calling
Iterator.next()
on the iterator returned here may throw a
SyncRuntimeException wrapping a SyncException such as might be
returned by get(Object)
SyncException
IVersion put(K key, V value) throws SyncException
put(Object, Versioned)
or putIfNotObsolete(Object, Versioned)
key
- The keyvalue
- The value
ObsoleteVersionException
SyncException
IVersion put(K key, Versioned<V> versioned) throws SyncException
key
- The keyversioned
- The value and its versioned
ObsoleteVersionException
SyncException
ObsoleteVersionException
- if the entry assoicated with the key
was locally modified by another thread after the get.boolean putIfNotObsolete(K key, Versioned<V> versioned) throws SyncException
key
- The keyversioned
- The versioned value
SyncException
void delete(K key) throws SyncException
delete(Object, IVersion)
should be used.
key
- The key
SyncException
void delete(K key, IVersion version) throws SyncException
IVersion
.
key
- The key to deleteversion
- The version of the key
SyncException
ObsoleteVersionException
- if the entry assoicated with the key
was locally modified by another thread after the get.void addStoreListener(IStoreListener<K> listener)
listener
- the IStoreListener
that will receive the
notifications
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |