Database Reference
In-Depth Information
updates. Methods like
incrby
are implemented with a simple
Command<E>
implementation:
public void
incrBy(
long
timestamp,String key,
long
value) {
aggregator.each(timestamp, key, value,
new
Command<Long>() {
public
String execute(
long
timestamp,
long
quantized,
String quantizedString, String key, Long
value) {
String k = key+":"+quantizedString;
jedis.incrBy(k, value);
return
k;
}
});
}
More complicated methods, such as
hincrby
, require more
parameters. These are passed as
final
arguments to the anonymous
command function:
public void
hincrBy(
long
timestamp,String
key,String field,
final long
by) {
aggregator.each(timestamp, key, field,
new
Command<String>() {
public
String execute(
long
timestamp,
long
quantized,
String quantizedString, String key,
String value) {
String k = key+":"+quantizedString;
jedis.hincrBy(key, value, by);
return
k;
}
});
}