|
Spring Data Key-Value | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.web.client.support.RestGatewaySupport
org.springframework.data.keyvalue.riak.core.AbstractRiakTemplate
org.springframework.data.keyvalue.riak.core.RiakKeyValueTemplate
public class RiakKeyValueTemplate
An implementation of KeyValueStoreOperations
and MapReduceOperations for the Riak
data store.
<bean id="riak" class="org.springframework.data.keyvalue.riak.core.RiakTemplate"
p:defaultUri="http://localhost:8098/riak/{bucket}/{key}"
p:mapReduceUri="http://localhost:8098/mapred"/>
To store and retrieve objects in Riak, use the setXXX and getXXX methods (example in
Groovy):
def obj = new TestObject(name: "My Name", age: 40)
riak.set([bucket: "mybucket", key: "mykey"], obj)
...
def name = riak.get([bucket: "mybucket", key: "mykey"]).name
println "Hello $name!"
You're key object should be one of: String encoding the bucket and key
together, separated by a colon. e.g. "mybucket:mykey"SimpleBucketKeyPair)Map with both a "bucket" and a "key" specified.String of only the key name, but specifying a bucket by using the KeyValueStoreMetaData annotation on the
object you're storing.
| Field Summary | |
|---|---|
protected RiakTemplate |
riak
|
| Fields inherited from class org.springframework.data.keyvalue.riak.core.AbstractRiakTemplate |
|---|
bucketKeyResolvers, cache, classLoader, conversionService, defaultQosParameters, defaultType, defaultUri, groovyPresent, httpDate, log, mapReduceUri, prefix, RIAK_CLIENT_ID, RIAK_META_CLASSNAME, RIAK_VCLOCK, useCache, workerPool |
| Fields inherited from class org.springframework.web.client.support.RestGatewaySupport |
|---|
logger |
| Constructor Summary | |
|---|---|
RiakKeyValueTemplate()
Take all the defaults. |
|
RiakKeyValueTemplate(ClientHttpRequestFactory requestFactory)
Use the specified ClientHttpRequestFactory. |
|
RiakKeyValueTemplate(String defaultUri,
String mapReduceUri)
Use the specified defaultUri and mapReduceUri. |
|
| Method Summary | ||
|---|---|---|
void |
afterPropertiesSet()
|
|
|
containsKey(K key)
Does the store contain this key? |
|
RiakMapReduceJob |
createMapReduceJob()
|
|
|
deleteKeys(K... keys)
Delete one or more keys from the store. |
|
Object |
execute(MapReduceJob job)
Execute a MapReduceJob
synchronously. |
|
|
execute(MapReduceJob job,
Class<T> targetType)
Execute a MapReduceJob synchronously, converting the result into the given type. |
|
|
get(K key)
Get a value at the specified key, trying to infer the type from either the bucket in which the value was stored, or (by default) as a java.util.Map. |
|
|
getAndSet(K key,
V value)
Get the old value at the specified key and replace it with the given value. |
|
|
getAndSetAsBytes(K key,
byte[] value)
Get the old value at the specified key as a byte array and replace it with the given bytes. |
|
|
getAndSetAsType(K key,
V value,
Class<T> requiredType)
Get the old value at the specified key and replace it with the given value, converting it to an instance of the given type. |
|
|
getAsBytes(K key)
Get the value at the specified key as a byte array. |
|
|
getAsBytesWithMetaData(K key)
|
|
|
getAsType(K key,
Class<T> requiredType)
Get the value at the specified key and convert it into an instance of the specified type. |
|
|
getBucketSchema(B bucket)
Get the properties of the specified bucket. |
|
|
getBucketSchema(B bucket,
boolean listKeys)
Get the properties of the bucket and specify whether or not to list the keys in that bucket. |
|
|
getMetaData(K key)
|
|
|
getValues(K... keys)
Variation on KeyValueStoreOperations.getValues(java.util.List) that uses varargs
instead of a java.util.List. |
|
|
getValues(List<K> keys)
Get all the values at the specified keys. |
|
|
getValuesAsType(Class<T> requiredType,
K... keys)
A variation on KeyValueStoreOperations.getValuesAsType(java.util.List, Class) that
takes uses varargs instead of a java.util.List. |
|
|
getValuesAsType(List<K> keys,
Class<T> requiredType)
Get all the values at the specified keys, converting the values into instances of the specified type. |
|
|
getWithMetaData(K key,
Class<T> requiredType)
|
|
|
link(K1 destination,
K2 source,
String tag)
Use Riak's native Link mechanism to link two entries together. |
|
|
linkWalk(K source,
String tag)
Use Riak's link walking mechanism to retrieve a multipart message that will be decoded like they were individual objects (e.g. using the built-in HttpMessageConverters of RestTemplate). |
|
|
set(K key,
V value)
Set a value at a specified key. |
|
|
set(K key,
V value,
QosParameters qosParams)
Variation on set() that allows the user to specify QosParameters. |
|
|
setAsBytes(K key,
byte[] value)
Set a value as a byte array at a specified key. |
|
|
setAsBytes(K key,
byte[] value,
QosParameters qosParams)
|
|
|
setIfKeyNonExistent(K key,
V value)
Set the value at the given key only if that key doesn't already exist. |
|
|
setIfKeyNonExistentAsBytes(K key,
byte[] value)
Set the value at the given key as a byte array only if that key doesn't already exist. |
|
|
setMultiple(Map<K,V> keysAndValues)
Convenience method to set multiple values as Key/Value pairs. |
|
|
setMultipleAsBytes(Map<K,byte[]> keysAndValues)
Convenience method to set multiple values as Key/byte[] pairs. |
|
|
setMultipleAsBytesIfKeysNonExistent(Map<K,byte[]> keysAndValues)
Variation on setting multiple values as byte arrays only if the key doesn't already exist. |
|
|
setMultipleIfKeysNonExistent(Map<K,V> keysAndValues)
Variation on setting multiple values only if the key doesn't already exist. |
|
|
setWithMetaData(K key,
V value,
Map<String,String> metaData)
|
|
|
setWithMetaData(K key,
V value,
Map<String,String> metaData,
QosParameters qosParams)
Variation on setWithMetaData() that allows the user to pass QosParameters. |
|
|
submit(MapReduceJob job)
Submit the job to run asynchronously. |
|
|
updateBucketSchema(B bucket,
Map<String,Object> props)
|
|
| Methods inherited from class org.springframework.data.keyvalue.riak.core.AbstractRiakTemplate |
|---|
checkCache, defaultHeaders, extractMediaType, extractMetaData, extractQosParameters, extractValue, getConversionService, getDefaultQosParameters, getDefaultType, getDefaultUri, getHost, getIgnoreNotFound, getMapReduceUri, getPort, getPrefix, getType, getType, getWorkerPool, isUseCache, resolveBucketKeyPair, setBeanClassLoader, setConversionService, setDefaultQosParameters, setDefaultType, setDefaultUri, setIgnoreNotFound, setMapReduceUri, setUseCache, setWorkerPool |
| Methods inherited from class org.springframework.web.client.support.RestGatewaySupport |
|---|
getRestTemplate, setRestTemplate |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected RiakTemplate riak
| Constructor Detail |
|---|
public RiakKeyValueTemplate()
public RiakKeyValueTemplate(ClientHttpRequestFactory requestFactory)
ClientHttpRequestFactory.
requestFactory -
public RiakKeyValueTemplate(String defaultUri,
String mapReduceUri)
defaultUri - mapReduceUri - | Method Detail |
|---|
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface InitializingBeanafterPropertiesSet in class AbstractRiakTemplateException
public <K,V> KeyValueStoreOperations set(K key,
V value)
KeyValueStoreOperations
set in interface KeyValueStoreOperations
public <K,V> KeyValueStoreOperations set(K key,
V value,
QosParameters qosParams)
KeyValueStoreOperationsQosParameters.
set in interface KeyValueStoreOperations
public <K> KeyValueStoreOperations setAsBytes(K key,
byte[] value)
KeyValueStoreOperations
setAsBytes in interface KeyValueStoreOperations
public <K> KeyValueStoreOperations setAsBytes(K key,
byte[] value,
QosParameters qosParams)
setAsBytes in interface KeyValueStoreOperations
public <K,V> KeyValueStoreOperations setWithMetaData(K key,
V value,
Map<String,String> metaData,
QosParameters qosParams)
KeyValueStoreOperationsQosParameters.
setWithMetaData in interface KeyValueStoreOperations
public <K,V> KeyValueStoreOperations setWithMetaData(K key,
V value,
Map<String,String> metaData)
setWithMetaData in interface KeyValueStoreOperationspublic <K> RiakMetaData getMetaData(K key)
public <K,T> RiakValue<T> getWithMetaData(K key,
Class<T> requiredType)
public <K,V> V get(K key)
KeyValueStoreOperationsjava.util.Map.
get in interface KeyValueStoreOperationsnull if not found.public <K> byte[] getAsBytes(K key)
KeyValueStoreOperations
getAsBytes in interface KeyValueStoreOperationsnull if not found.public <K> RiakValue<byte[]> getAsBytesWithMetaData(K key)
public <K,T> T getAsType(K key,
Class<T> requiredType)
KeyValueStoreOperations
getAsType in interface KeyValueStoreOperationsnull if not found.
public <K,V> V getAndSet(K key,
V value)
KeyValueStoreOperations
getAndSet in interface KeyValueStoreOperations
public <K> byte[] getAndSetAsBytes(K key,
byte[] value)
KeyValueStoreOperations
getAndSetAsBytes in interface KeyValueStoreOperations
public <K,V,T> T getAndSetAsType(K key,
V value,
Class<T> requiredType)
KeyValueStoreOperations
getAndSetAsType in interface KeyValueStoreOperationsrequiredType - The type to convert the value to.
public <K,V> List<V> getValues(List<K> keys)
KeyValueStoreOperations
getValues in interface KeyValueStoreOperationspublic <K,V> List<V> getValues(K... keys)
KeyValueStoreOperationsKeyValueStoreOperations.getValues(java.util.List) that uses varargs
instead of a java.util.List.
getValues in interface KeyValueStoreOperations
public <K,T> List<T> getValuesAsType(List<K> keys,
Class<T> requiredType)
KeyValueStoreOperations
getValuesAsType in interface KeyValueStoreOperations
public <T,K> List<T> getValuesAsType(Class<T> requiredType,
K... keys)
KeyValueStoreOperationsKeyValueStoreOperations.getValuesAsType(java.util.List, Class) that
takes uses varargs instead of a java.util.List.
getValuesAsType in interface KeyValueStoreOperations
public <K,V> KeyValueStoreOperations setIfKeyNonExistent(K key,
V value)
KeyValueStoreOperations
setIfKeyNonExistent in interface KeyValueStoreOperations
public <K> KeyValueStoreOperations setIfKeyNonExistentAsBytes(K key,
byte[] value)
KeyValueStoreOperations
setIfKeyNonExistentAsBytes in interface KeyValueStoreOperationspublic <K,V> KeyValueStoreOperations setMultiple(Map<K,V> keysAndValues)
KeyValueStoreOperations
setMultiple in interface KeyValueStoreOperationspublic <K> KeyValueStoreOperations setMultipleAsBytes(Map<K,byte[]> keysAndValues)
KeyValueStoreOperations
setMultipleAsBytes in interface KeyValueStoreOperationspublic <K,V> KeyValueStoreOperations setMultipleIfKeysNonExistent(Map<K,V> keysAndValues)
KeyValueStoreOperations
setMultipleIfKeysNonExistent in interface KeyValueStoreOperationspublic <K> KeyValueStoreOperations setMultipleAsBytesIfKeysNonExistent(Map<K,byte[]> keysAndValues)
KeyValueStoreOperations
setMultipleAsBytesIfKeysNonExistent in interface KeyValueStoreOperationspublic <K> boolean containsKey(K key)
KeyValueStoreOperations
containsKey in interface KeyValueStoreOperationstrue if the key exists, false otherwise.public <K> boolean deleteKeys(K... keys)
KeyValueStoreOperations
deleteKeys in interface KeyValueStoreOperationstrue if all keys were successfully deleted, false
otherwise.public RiakMapReduceJob createMapReduceJob()
public Object execute(MapReduceJob job)
MapReduceOperationsMapReduceJob
synchronously.
execute in interface MapReduceOperations
public <T> T execute(MapReduceJob job,
Class<T> targetType)
MapReduceOperations
execute in interface MapReduceOperationspublic <T> Future<List<T>> submit(MapReduceJob job)
MapReduceOperations
submit in interface MapReduceOperations
public <K1,K2> RiakKeyValueTemplate link(K1 destination,
K2 source,
String tag)
destination - Key to the child objectsource - Key to the parent objecttag - The tag for this relationship
public <T,K> T linkWalk(K source,
String tag)
source - tag -
public <B> Map<String,Object> getBucketSchema(B bucket)
KeyValueStoreOperations
getBucketSchema in interface KeyValueStoreOperations
public <B> Map<String,Object> getBucketSchema(B bucket,
boolean listKeys)
KeyValueStoreOperations
getBucketSchema in interface KeyValueStoreOperations
public <B> KeyValueStoreOperations updateBucketSchema(B bucket,
Map<String,Object> props)
updateBucketSchema in interface KeyValueStoreOperations
|
Spring Data Key-Value | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||