public class KeyValueClient extends Object
Modifier and Type | Method and Description |
---|---|
boolean |
acquireLock(String key,
String session)
Aquire a lock for a given key.
|
boolean |
acquireLock(String key,
String value,
String session)
Aquire a lock for a given key.
|
void |
deleteKey(String key)
Deletes a specified key.
|
void |
deleteKeys(String key)
Deletes a specified key and any below it.
|
List<String> |
getKeys(String key)
Retrieves a list of matching keys for the given key.
|
com.google.common.base.Optional<String> |
getSession(String key)
Retrieves a session string for a specific key from the key/value store.
|
com.google.common.base.Optional<Value> |
getValue(String key)
Retrieves a
Value for a specific key
from the key/value store. |
com.google.common.base.Optional<Value> |
getValue(String key,
QueryOptions queryOptions)
Retrieves a
Value for a specific key
from the key/value store. |
void |
getValue(String key,
QueryOptions queryOptions,
ConsulResponseCallback<com.google.common.base.Optional<Value>> callback)
Asynchronously retrieves a
Value for a specific key
from the key/value store. |
com.google.common.base.Optional<String> |
getValueAsString(String key)
Retrieves a string value for a specific key from the key/value store.
|
List<Value> |
getValues(String key)
Retrieves a list of
Value objects for a specific key
from the key/value store. |
List<Value> |
getValues(String key,
QueryOptions queryOptions)
Retrieves a list of
Value objects for a specific key
from the key/value store. |
void |
getValues(String key,
QueryOptions queryOptions,
ConsulResponseCallback<List<Value>> callback)
Asynchronously retrieves a list of
Value objects for a specific key
from the key/value store. |
List<String> |
getValuesAsString(String key)
Retrieves a list of string values for a specific key from the key/value
store.
|
boolean |
putValue(String key)
Puts a null value into the key/value store.
|
boolean |
putValue(String key,
String value)
Puts a value into the key/value store.
|
boolean |
putValue(String key,
String value,
long flags)
Puts a value into the key/value store.
|
boolean |
putValue(String key,
String value,
long flags,
PutOptions putOptions)
Puts a value into the key/value store.
|
boolean |
releaseLock(String key,
String sessionId)
Releases the lock for a given service and session.
|
public com.google.common.base.Optional<Value> getValue(String key)
Value
for a specific key
from the key/value store.
GET /v1/kv/{key}key
- The key to retrieve.Optional
containing the value or Optional.absent()
public com.google.common.base.Optional<Value> getValue(String key, QueryOptions queryOptions)
Value
for a specific key
from the key/value store.
GET /v1/kv/{key}key
- The key to retrieve.queryOptions
- The query options.Optional
containing the value or Optional.absent()
public void getValue(String key, QueryOptions queryOptions, ConsulResponseCallback<com.google.common.base.Optional<Value>> callback)
Value
for a specific key
from the key/value store.
GET /v1/kv/{key}key
- The key to retrieve.queryOptions
- The query options.callback
- Callback implemented by callee to handle results.public List<Value> getValues(String key)
Value
objects for a specific key
from the key/value store.
GET /v1/kv/{key}?recursekey
- The key to retrieve.Value
objects.public List<Value> getValues(String key, QueryOptions queryOptions)
Value
objects for a specific key
from the key/value store.
GET /v1/kv/{key}?recursekey
- The key to retrieve.queryOptions
- The query options.Value
objects.public void getValues(String key, QueryOptions queryOptions, ConsulResponseCallback<List<Value>> callback)
Value
objects for a specific key
from the key/value store.
GET /v1/kv/{key}?recursekey
- The key to retrieve.queryOptions
- The query options.callback
- Callback implemented by callee to handle results.public com.google.common.base.Optional<String> getValueAsString(String key)
key
- The key to retrieve.Optional
containing the value as a string or
Optional.absent()
public List<String> getValuesAsString(String key)
key
- The key to retrieve.public boolean putValue(String key)
key
- The key to use as index.true
if the value was successfully indexed.public boolean putValue(String key, String value)
key
- The key to use as index.value
- The value to index.true
if the value was successfully indexed.public boolean putValue(String key, String value, long flags)
key
- The key to use as index.value
- The value to index.flags
- The flags for this key.true
if the value was successfully indexed.public boolean putValue(String key, String value, long flags, PutOptions putOptions)
key
- The key to use as index.value
- The value to index.putOptions
- PUT options (e.g. wait, acquire).true
if the value was successfully indexed.public List<String> getKeys(String key)
key
- The key to retrieve.public void deleteKey(String key)
key
- The key to delete.public void deleteKeys(String key)
key
- The key to delete.public boolean acquireLock(String key, String session)
key
- The key to acquire the lock.session
- The session to acquire lock.public boolean acquireLock(String key, String value, String session)
key
- The key to acquire the lock.session
- The session to acquire lock.value
- key value (usually - application specific info about the lock requester)public com.google.common.base.Optional<String> getSession(String key)
key
- The key to retrieve.Optional
containing the value as a string or
Optional.absent()
public boolean releaseLock(String key, String sessionId)
key
- identifying the service.sessionId
- SessionInfo
.Copyright © 2016. All rights reserved.