public final class UpdateValue extends RiakCommand<UpdateValue.Response,Location>
The UpdateValue command completely encapsulates the typical read/modify/write cycle used with data in Riak.
The object specified by the given Location
will be fetched from Riak and have the ConflictResolver
stored in
the ConflictResolverFactory
applied. The resolved
object is then passed to your UpdateValue.Update
and the result stored back into Riak.
class AppendUpdate extends UpdateValue.Update<MyPojo>
{
private final String update;
public AppendUpdate(String update)
{
this.update = update;
}
{@literal @Override}
public MyPojo apply(MyPojo original)
{
if (original == null)
{
original = new MyPojo();
}
original.value += update;
return original;
}
}
Namespace ns = new Namespace("my_type", "my_bucket");
Location loc = new Location(ns, "my_key");
AppendUpdate update = new AppendUpdate("append this string");
UpdateValue uv =
new UpdateValue.Builder(loc).withUpdate(update).build();
UpdateValue.Response response = client.execute(uv);
Modifier and Type | Class and Description |
---|---|
static class |
UpdateValue.Builder
Used to construct an UpdateValue command.
|
static class |
UpdateValue.Response |
static class |
UpdateValue.Update<T>
An update on a Riak object
|
Modifier and Type | Method and Description |
---|---|
protected RiakFuture<UpdateValue.Response,Location> |
executeAsync(RiakCluster cluster) |
execute
protected RiakFuture<UpdateValue.Response,Location> executeAsync(RiakCluster cluster)
executeAsync
in class RiakCommand<UpdateValue.Response,Location>
Copyright © 2014. All rights reserved.