@SuppressWarnings("unchecked")
 public Future<Long> zadd(K key, Object... scoresAndValues) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec).addKey(key);
   for (int i = 0; i < scoresAndValues.length; i += 2) {
     args.add((Double) scoresAndValues[i]);
     args.addValue((V) scoresAndValues[i + 1]);
   }
   return dispatch(ZADD, new IntegerOutput<K, V>(codec), args);
 }
Exemple #2
0
 /**
  * Encode and write this command to the supplied buffer using the new <a
  * href="http://redis.io/topics/protocol">Unified Request Protocol</a>.
  *
  * @param buf Buffer to write to.
  */
 void encode(ChannelBuffer buf) {
   buf.writeByte('*');
   writeInt(buf, 1 + (args != null ? args.count() : 0));
   buf.writeBytes(CRLF);
   buf.writeByte('$');
   writeInt(buf, type.bytes.length);
   buf.writeBytes(CRLF);
   buf.writeBytes(type.bytes);
   buf.writeBytes(CRLF);
   if (args != null) {
     buf.writeBytes(args.buffer());
   }
   /*byte[] array = buf.array();
   String s = new String(array);
   System.out.println("请求报文:" + s);*/
 }
 public Future<Long> bitopAnd(K destination, K... keys) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.add(AND).addKey(destination).addKeys(keys);
   return dispatch(BITOP, new IntegerOutput<K, V>(codec), args);
 }
 public Future<Long> zunionstore(K destination, ZStoreArgs storeArgs, K... keys) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.addKey(destination).add(keys.length).addKeys(keys);
   storeArgs.build(args);
   return dispatch(ZUNIONSTORE, new IntegerOutput<K, V>(codec), args);
 }
 public Future<Long> bitcount(K key, long start, long end) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.addKey(key).add(start).add(end);
   return dispatch(BITCOUNT, new IntegerOutput<K, V>(codec), args);
 }
 public Future<List<ScoredValue<V>>> zrevrangebyscoreWithScores(
     K key, String max, String min, long offset, long count) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.addKey(key).add(max).add(min).add(WITHSCORES).add(LIMIT).add(offset).add(count);
   return dispatch(ZREVRANGEBYSCORE, new ScoredValueListOutput<K, V>(codec), args);
 }
 public Future<List<ScoredValue<V>>> zrevrangeWithScores(K key, long start, long stop) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.addKey(key).add(start).add(stop).add(WITHSCORES);
   return dispatch(ZREVRANGE, new ScoredValueListOutput<K, V>(codec), args);
 }
 public Future<List<ScoredValue<V>>> zrangebyscoreWithScores(K key, String min, String max) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.addKey(key).add(min).add(max).add(WITHSCORES);
   return dispatch(ZRANGEBYSCORE, new ScoredValueListOutput<K, V>(codec), args);
 }
 public Future<List<V>> zrangebyscore(K key, String min, String max, long offset, long count) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.addKey(key).add(min).add(max).add(LIMIT).add(offset).add(count);
   return dispatch(ZRANGEBYSCORE, new ValueListOutput<K, V>(codec), args);
 }
 public void shutdown(boolean save) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   dispatch(SHUTDOWN, new StatusOutput<K, V>(codec), save ? args.add(SAVE) : args.add(NOSAVE));
 }
 public Future<List<Boolean>> scriptExists(String... digests) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec).add(EXISTS);
   for (String sha : digests) args.add(sha);
   return dispatch(SCRIPT, new BooleanListOutput<K, V>(codec), args);
 }
 public Future<String> migrate(String host, int port, K key, int db, long timeout) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.add(host).add(port).addKey(key).add(db).add(timeout);
   return dispatch(MIGRATE, new StatusOutput<K, V>(codec), args);
 }
 public Future<Long> linsert(K key, boolean before, V pivot, V value) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.addKey(key).add(before ? BEFORE : AFTER).addValue(pivot).addValue(value);
   return dispatch(LINSERT, new IntegerOutput<K, V>(codec), args);
 }
 public <T> Future<T> evalsha(String digest, ScriptOutputType type, K[] keys, V... values) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.add(digest).add(keys.length).addKeys(keys).addValues(values);
   CommandOutput<K, V, T> output = newScriptOutput(codec, type);
   return dispatch(EVALSHA, output, args);
 }
 public Future<V> brpoplpush(long timeout, K source, K destination) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.addKey(source).addKey(destination).add(timeout);
   return dispatch(BRPOPLPUSH, new ValueOutput<K, V>(codec), args);
 }
 public Future<Long> bitopNot(K destination, K source) {
   CommandArgs<K, V> args = new CommandArgs<K, V>(codec);
   args.add(NOT).addKey(destination).addKey(source);
   return dispatch(BITOP, new IntegerOutput<K, V>(codec), args);
 }