|
Spring Data Key-Value | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.client.support.RestGatewaySupport org.springframework.data.keyvalue.riak.core.AbstractRiakTemplate org.springframework.data.keyvalue.riak.core.RiakTemplate
public class RiakTemplate
An implementation of BucketKeyValueStoreOperations
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("mybucket", "mykey", obj)
...
def name = riak.get("mybucket", "mykey").name
println "Hello $name!"
Field Summary |
---|
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 | |
---|---|
RiakTemplate()
Take all the defaults. |
|
RiakTemplate(ClientHttpRequestFactory requestFactory)
Use the specified ClientHttpRequestFactory . |
|
RiakTemplate(String defaultUri,
String mapReduceUri)
Use the specified defaultUri and mapReduceUri. |
Method Summary | ||
---|---|---|
|
containsKey(B bucket,
K key)
Variant of KeyValueStoreOperations.containsKey(Object)
that takes a discreet bucket and key pair. |
|
|
delete(B bucket,
K key)
Delete a specific entry from this data store. |
|
|
deleteKeys(K... keys)
|
|
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(B bucket,
K key)
Variant of KeyValueStoreOperations.get(Object)
that takes a discreet bucket and key pair. |
|
|
getAndSet(B bucket,
K key,
V value)
Variant of KeyValueStoreOperations.getAndSet(Object,
Object) that takes a discreet bucket and key pair. |
|
|
getAndSetAsBytes(B bucket,
K key,
byte[] value)
Variant of KeyValueStoreOperations.getAndSetAsBytes(Object,
byte[]) that takes a discreet bucket and key pair. |
|
|
getAndSetAsType(B bucket,
K key,
V value,
Class<T> requiredType)
Variant of KeyValueStoreOperations.getAndSetAsType(Object,
Object, Class) that takes a discreet bucket and key pair. |
|
|
getAsBytes(B bucket,
K key)
Variant of KeyValueStoreOperations.getAsBytes(Object)
that takes a discreet bucket and key pair. |
|
|
getAsBytesWithMetaData(B bucket,
K key)
|
|
|
getAsType(B bucket,
K key,
Class<T> requiredType)
Variant of KeyValueStoreOperations.getAsType(Object,
Class) that takes a discreet bucket and key pair. |
|
|
getBucketSchema(B bucket)
|
|
|
getBucketSchema(B bucket,
boolean listKeys)
|
|
|
getMetaData(B bucket,
K key)
|
|
|
getValues(K... keys)
|
|
|
getValues(List<K> keys)
|
|
|
getValuesAsType(Class<T> requiredType,
K... keys)
|
|
|
getValuesAsType(List<K> keys,
Class<T> requiredType)
|
|
|
getWithMetaData(B bucket,
K key,
Class<T> requiredType)
|
|
|
link(B1 destBucket,
K1 destKey,
B2 sourceBucket,
K2 sourceKey,
String tag)
Use Riak's native Link mechanism to link two entries together. |
|
|
linkWalk(B bucket,
K key,
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). |
|
|
linkWalkAsType(B bucket,
K key,
String tag,
Class<T> requiredType)
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) and return the result as a list of objects of one of: The type specified by requiredType If that's null, try using the bucket name
in which the object was stored If all else fails, use a Map
|
|
|
put(B bucket,
V value)
Save an object to Riak and let it generate an ID for it. |
|
|
put(B bucket,
V value,
Map<String,String> metaData)
Save an object to Riak and let it generate an ID for it. |
|
|
set(B bucket,
K key,
V value)
Variant of KeyValueStoreOperations.set(Object,
Object) that takes a discreet bucket and key pair. |
|
|
set(B bucket,
K key,
V value,
QosParameters qosParams)
Variant of KeyValueStoreOperations.set(Object,
Object, QosParameters) that takes a discreet bucket and key pair. |
|
|
setAsBytes(B bucket,
K key,
byte[] value)
Variant of KeyValueStoreOperations.setAsBytes(Object,
byte[]) that takes a discreet bucket and key pair. |
|
|
setAsBytes(B bucket,
K key,
byte[] value,
QosParameters qosParams)
Variant of KeyValueStoreOperations.setAsBytes(Object,
byte[], QosParameters) that takes a discreet bucket and key pair. |
|
|
setIfKeyNonExistent(B bucket,
K key,
V value)
Variant of KeyValueStoreOperations.setIfKeyNonExistent(Object,
Object) that takes a discreet bucket and key pair. |
|
|
setIfKeyNonExistentAsBytes(B bucket,
K key,
byte[] value)
Variant of KeyValueStoreOperations.setIfKeyNonExistentAsBytes(Object,
byte[]) that takes a discreet bucket and key pair. |
|
|
setWithMetaData(B bucket,
K key,
V value,
Map<String,String> metaData)
Variant of KeyValueStoreOperations.setWithMetaData(Object,
Object, java.util.Map) that takes a discreet bucket and key pair. |
|
|
setWithMetaData(B bucket,
K key,
V value,
Map<String,String> metaData,
QosParameters qosParams)
Variant of KeyValueStoreOperations.setWithMetaData(Object,
Object, java.util.Map, QosParameters) that takes a discreet bucket and key pair. |
|
|
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 |
---|
afterPropertiesSet, 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 |
Constructor Detail |
---|
public RiakTemplate()
public RiakTemplate(ClientHttpRequestFactory requestFactory)
ClientHttpRequestFactory
.
requestFactory
- public RiakTemplate(String defaultUri, String mapReduceUri)
defaultUri
- mapReduceUri
- Method Detail |
---|
public <B,K,V> BucketKeyValueStoreOperations set(B bucket, K key, V value)
BucketKeyValueStoreOperations
KeyValueStoreOperations.set(Object,
Object)
that takes a discreet bucket and key pair.
set
in interface BucketKeyValueStoreOperations
public <B,K,V> BucketKeyValueStoreOperations set(B bucket, K key, V value, QosParameters qosParams)
BucketKeyValueStoreOperations
KeyValueStoreOperations.set(Object,
Object, QosParameters)
that takes a discreet bucket and key pair.
set
in interface BucketKeyValueStoreOperations
public <B,K> BucketKeyValueStoreOperations setAsBytes(B bucket, K key, byte[] value)
BucketKeyValueStoreOperations
KeyValueStoreOperations.setAsBytes(Object,
byte[])
that takes a discreet bucket and key pair.
setAsBytes
in interface BucketKeyValueStoreOperations
public <B,K> BucketKeyValueStoreOperations setAsBytes(B bucket, K key, byte[] value, QosParameters qosParams)
BucketKeyValueStoreOperations
KeyValueStoreOperations.setAsBytes(Object,
byte[], QosParameters)
that takes a discreet bucket and key pair.
setAsBytes
in interface BucketKeyValueStoreOperations
public <B,K,V> BucketKeyValueStoreOperations setWithMetaData(B bucket, K key, V value, Map<String,String> metaData, QosParameters qosParams)
BucketKeyValueStoreOperations
KeyValueStoreOperations.setWithMetaData(Object,
Object, java.util.Map, QosParameters)
that takes a discreet bucket and key pair.
setWithMetaData
in interface BucketKeyValueStoreOperations
public <B,K,V> BucketKeyValueStoreOperations setWithMetaData(B bucket, K key, V value, Map<String,String> metaData)
BucketKeyValueStoreOperations
KeyValueStoreOperations.setWithMetaData(Object,
Object, java.util.Map)
that takes a discreet bucket and key pair.
setWithMetaData
in interface BucketKeyValueStoreOperations
public <B,V> String put(B bucket, V value)
bucket
- value
-
public <B,V> String put(B bucket, V value, Map<String,String> metaData)
bucket
- value
- metaData
-
public <B,K> RiakMetaData getMetaData(B bucket, K key)
public <B,K,T> RiakValue<T> getWithMetaData(B bucket, K key, Class<T> requiredType)
public <B,K,T> T get(B bucket, K key)
BucketKeyValueStoreOperations
KeyValueStoreOperations.get(Object)
that takes a discreet bucket and key pair.
get
in interface BucketKeyValueStoreOperations
public <B,K> byte[] getAsBytes(B bucket, K key)
BucketKeyValueStoreOperations
KeyValueStoreOperations.getAsBytes(Object)
that takes a discreet bucket and key pair.
getAsBytes
in interface BucketKeyValueStoreOperations
public <B,K> RiakValue<byte[]> getAsBytesWithMetaData(B bucket, K key)
public <B,K,T> T getAsType(B bucket, K key, Class<T> requiredType)
BucketKeyValueStoreOperations
KeyValueStoreOperations.getAsType(Object,
Class)
that takes a discreet bucket and key pair.
getAsType
in interface BucketKeyValueStoreOperations
public <B,K,V> V getAndSet(B bucket, K key, V value)
BucketKeyValueStoreOperations
KeyValueStoreOperations.getAndSet(Object,
Object)
that takes a discreet bucket and key pair.
getAndSet
in interface BucketKeyValueStoreOperations
public <B,K> byte[] getAndSetAsBytes(B bucket, K key, byte[] value)
BucketKeyValueStoreOperations
KeyValueStoreOperations.getAndSetAsBytes(Object,
byte[])
that takes a discreet bucket and key pair.
getAndSetAsBytes
in interface BucketKeyValueStoreOperations
public <B,K,V,T> T getAndSetAsType(B bucket, K key, V value, Class<T> requiredType)
BucketKeyValueStoreOperations
KeyValueStoreOperations.getAndSetAsType(Object,
Object, Class)
that takes a discreet bucket and key pair.
getAndSetAsType
in interface BucketKeyValueStoreOperations
public <K,V> List<V> getValues(List<K> keys)
public <K,V> List<V> getValues(K... keys)
public <K,T> List<T> getValuesAsType(List<K> keys, Class<T> requiredType)
public <T,K> List<T> getValuesAsType(Class<T> requiredType, K... keys)
public <B,K,V> BucketKeyValueStoreOperations setIfKeyNonExistent(B bucket, K key, V value)
BucketKeyValueStoreOperations
KeyValueStoreOperations.setIfKeyNonExistent(Object,
Object)
that takes a discreet bucket and key pair.
setIfKeyNonExistent
in interface BucketKeyValueStoreOperations
public <B,K> BucketKeyValueStoreOperations setIfKeyNonExistentAsBytes(B bucket, K key, byte[] value)
BucketKeyValueStoreOperations
KeyValueStoreOperations.setIfKeyNonExistentAsBytes(Object,
byte[])
that takes a discreet bucket and key pair.
setIfKeyNonExistentAsBytes
in interface BucketKeyValueStoreOperations
public <B,K> boolean containsKey(B bucket, K key)
BucketKeyValueStoreOperations
KeyValueStoreOperations.containsKey(Object)
that takes a discreet bucket and key pair.
containsKey
in interface BucketKeyValueStoreOperations
public <B,K> boolean delete(B bucket, K key)
BucketKeyValueStoreOperations
delete
in interface BucketKeyValueStoreOperations
public <K> boolean deleteKeys(K... keys)
public Object execute(MapReduceJob job)
MapReduceOperations
MapReduceJob
synchronously.
execute
in interface MapReduceOperations
public <T> T execute(MapReduceJob job, Class<T> targetType)
MapReduceOperations
execute
in interface MapReduceOperations
public <T> Future<List<T>> submit(MapReduceJob job)
MapReduceOperations
submit
in interface MapReduceOperations
public <B1,K1,B2,K2> RiakTemplate link(B1 destBucket, K1 destKey, B2 sourceBucket, K2 sourceKey, String tag)
destBucket
- Bucket of child entrydestKey
- Key of child entrysourceBucket
- Bucket of parent entrysourceKey
- Key of parent entrytag
- Tag for this relationship
public <B,T,K> T linkWalk(B bucket, K key, String tag)
bucket
- key
- tag
-
public <B,T,K> T linkWalkAsType(B bucket, K key, String tag, Class<T> requiredType)
requiredType
Map
bucket
- key
- tag
- requiredType
-
public <B> Map<String,Object> getBucketSchema(B bucket)
public <B> Map<String,Object> getBucketSchema(B bucket, boolean listKeys)
public <B> BucketKeyValueStoreOperations updateBucketSchema(B bucket, Map<String,Object> props)
|
Spring Data Key-Value | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |