@Test public void zincrby() { rc.del(a("myzset")); eq(1, rc.zadd(a("myzset", "1", "one"))); eq(1, rc.zadd(a("myzset", "2", "two"))); eq("3", rc.zincrby("myzset", "2", "one")); eq(a("two", "2", "one", "3"), rc.zrange("myzset", "0", "-1", WITHSCORES)); }
@Test public void zremrangebyscore() { rc.del(a("myzset")); eq(1, rc.zadd(a("myzset", "1", "one"))); eq(1, rc.zadd(a("myzset", "2", "two"))); eq(1, rc.zadd(a("myzset", "3", "three"))); eq(1, rc.zremrangebyscore("myzset", "-inf", "(2")); eq(a("two", "2", "three", "3"), rc.zrange("myzset", "0", "-1", WITHSCORES)); }
@Test public void zrem() { rc.del(a("myzset")); eq(1, rc.zadd(a("myzset", "1", "one"))); eq(1, rc.zadd(a("myzset", "2", "two"))); eq(1, rc.zadd(a("myzset", "3", "three"))); eq(1, rc.zrem_("myzset", "two")); eq(a("one", "1", "three", "3"), rc.zrange("myzset", "0", "-1", WITHSCORES)); }
public Set<Tuple> zRangeWithScores(byte[] key, long start, long end) { try { if (isPipelined()) { pipeline(pipeline.zrange(key, start, end, SrpUtils.WITHSCORES)); return null; } return SrpUtils.convertTuple(client.zrange(key, start, end, SrpUtils.WITHSCORES)); } catch (Exception ex) { throw convertSrpAccessException(ex); } }
public Set<byte[]> zRange(byte[] key, long start, long end) { try { if (isPipelined()) { pipeline(pipeline.zrange(key, start, end, null)); return null; } return SrpUtils.toSet(client.zrange(key, start, end, null).data()); } catch (Exception ex) { throw convertSrpAccessException(ex); } }
@Test public void zinterstore() { rc.del(a("zset1", "zset2")); eq(1, rc.zadd(a("zset1", "1", "one"))); eq(1, rc.zadd(a("zset1", "2", "two"))); eq(1, rc.zadd(a("zset2", "1", "one"))); eq(1, rc.zadd(a("zset2", "2", "two"))); eq(1, rc.zadd(a("zset2", "3", "three"))); eq(2, rc.zinterstore(a("out", "2", "zset1", "zset2", WEIGHTS, "2", "3"))); eq(a("one", "5", "two", "10"), rc.zrange("out", "0", "-1", WITHSCORES)); }