public class CounterObject extends Object implements RiakOperation<Long>
A counter is uniquely identified by its name (key) in a bucket. The first time you increment a counter, it is created. A counter can be decremented by incrementing it by a negative value;
// Create and increment a counter by 1
CounterObject c = bucket.counter("myCounter");
Long l = c.increment(1L).returnValue(true).execute();
// fetch an existing counter value
l = bucket.counter("myCounter").execute();
Constructor and Description |
---|
CounterObject(RawClient rawClient,
String bucket,
String counter) |
Modifier and Type | Method and Description |
---|---|
CounterObject |
basicQuorum(boolean basicQuorum)
fail early if a quorum of error/notfounds are reached before a successful
read (for a fetch operation)
|
CounterObject |
dw(int dw)
The durable write quorum for an increment operation
|
CounterObject |
dw(Quora dw)
The durable write quorum for for an increment operation
|
CounterObject |
dw(Quorum dw)
The durable write quorum for an increment operation
|
Long |
execute()
Execute this counter operation
|
CounterObject |
increment(Long increment) |
CounterObject |
notFoundOK(boolean notFoundOK)
if notfound_ok counts towards r count (for a fetch operation)
|
CounterObject |
pr(int pr)
The pr for a fetch operation
|
CounterObject |
pr(Quora pr)
The pr for a fetch operation
|
CounterObject |
pr(Quorum pr)
The pr for a fetch operation
|
CounterObject |
pw(int pw)
Set the primary write quorum for an increment operation, takes precedence
over w.
|
CounterObject |
pw(Quora pw)
Set the primary write quorum for an increment operation, takes precedence
over w.
|
CounterObject |
pw(Quorum pw)
Set the primary write quorum for an increment operation, takes precedence
over w.
|
CounterObject |
r(int r)
Set the read quorum for a fetch operation
|
CounterObject |
r(Quora r)
Set the read quorum for a fetch operation
|
CounterObject |
r(Quorum r)
Set the read quorum for a fetch operation
|
CounterObject |
returnValue(boolean returnValue)
Should an increment operation return the new value?
|
CounterObject |
w(int w)
Set the write quorum for an increment operation
|
CounterObject |
w(Quora w)
Set the write quorum for an increment operation
|
CounterObject |
w(Quorum w)
Set the write quorum for an increment operation
|
public CounterObject increment(Long increment)
public CounterObject pw(int pw)
pw
- StoreMeta.Builder.pw(int)
public CounterObject pw(Quora pw)
pw
- StoreMeta.Builder.pw(com.basho.riak.client.cap.Quora)
public CounterObject pw(Quorum pw)
pw
- StoreMeta.Builder.pw(com.basho.riak.client.cap.Quorum)
public CounterObject w(int w)
w
- StoreMeta.Builder.w(int)
public CounterObject w(Quora w)
w
- StoreMeta.Builder.w(com.basho.riak.client.cap.Quora)
public CounterObject w(Quorum w)
w
- StoreMeta.Builder.w(com.basho.riak.client.cap.Quorum)
public CounterObject dw(int dw)
dw
- StoreMeta.Builder.dw(int)
public CounterObject dw(Quora dw)
dw
- StoreMeta.Builder.dw(com.basho.riak.client.cap.Quora)
public CounterObject dw(Quorum dw)
dw
- StoreMeta.Builder.dw(com.basho.riak.client.cap.Quorum)
public CounterObject returnValue(boolean returnValue)
returnValue
- public CounterObject r(int r)
r
- the read quorum for the pre-store fetchFetchMeta.Builder.r(int)
public CounterObject r(Quora r)
r
- the read quorum for the pre-store fetchFetchMeta.Builder.r(com.basho.riak.client.cap.Quora)
public CounterObject r(Quorum r)
r
- the read quorum for the pre-store fetchFetchMeta.Builder.r(com.basho.riak.client.cap.Quorum)
public CounterObject pr(int pr)
pr
- FetchMeta.Builder.pr(int)
public CounterObject pr(Quora pr)
pr
- FetchMeta.Builder.pr(com.basho.riak.client.cap.Quora)
public CounterObject pr(Quorum pr)
pr
- FetchMeta.Builder.pr(Quorum)
public CounterObject notFoundOK(boolean notFoundOK)
notFoundOK
- FetchMeta.Builder.notFoundOK(boolean)
public CounterObject basicQuorum(boolean basicQuorum)
basicQuorum
- FetchMeta.Builder.basicQuorum(boolean)
public Long execute() throws RiakException
execute
in interface RiakOperation<Long>
returnValue(boolean)
RiakException
Copyright © 2013. All Rights Reserved.