@Test public void del() { rc.del(a("key1", "key2", "key3")); eq("OK", rc.set("key1", "Hello")); eq("OK", rc.set("key2", "World")); eq(2, rc.del(a("key1", "key2", "key3"))); }
@Test public void append() { rc.del(a("mykey")); eq(5, rc.append("mykey", "Hello")); eq(11, rc.append("mykey", " World")); eq("Hello World", rc.get("mykey")); }
@Test public void zcard() { rc.del(a("myzset")); eq(1, rc.zadd(a("myzset", "1", "one"))); eq(1, rc.zadd(a("myzset", "2", "two"))); eq(2, rc.zcard("myzset")); }
@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 zrevrank() { 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(2, (IntegerReply) rc.zrevrank("myzset", "one")); eq(null, (BulkReply) rc.zrevrank("myzset", "four")); }
@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)); }
@Test public void zcount() { 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(3, rc.zcount("myzset", "-inf", "inf")); eq(2, rc.zcount("myzset", "(1", "3")); }
@Test public void zrevrange() { 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(a("three", "two", "one"), rc.zrevrange_("myzset", 0, -1)); eq(a("one"), rc.zrevrange_("myzset", 2, 3)); eq(a("two", "one"), rc.zrevrange_("myzset", -2, -1)); }
@Test public void zrange() { 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(a("one", "two", "three"), rc.zrange_("myzset", "0", "-1")); eq(a("three"), rc.zrange_("myzset", "2", "3")); eq(a("two", "three"), rc.zrange_("myzset", "-2", "-1")); }
public Long del(byte[]... keys) { try { if (isPipelined()) { pipeline(pipeline.del((Object[]) keys)); return null; } return client.del((Object[]) keys).data(); } catch (Exception ex) { throw convertSrpAccessException(ex); } }
@Test public void zrevrangebyscore() { 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(a("three", "two", "one"), rc.zrevrangebyscore_("myzset", "+inf", "-inf")); eq(a("two", "one"), rc.zrevrangebyscore_("myzset", 2, 1)); eq(a("two"), rc.zrevrangebyscore_("myzset", 2, "(1")); eq(a(), rc.zrevrangebyscore_("myzset", "(2", "(1")); }
@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)); }
@Test public void brpop() { rc.del(a("list1", "list2")); eq(3, rc.rpush("list1", a("a", "b", "c"))); eq(a("list1", "c"), rc.brpop(a("list1", "list2", "0"))); }
@Test public void zscore() { rc.del(a("myzset")); eq(1, rc.zadd(a("myzset", "1", "one"))); eq("1", rc.zscore("myzset", "one")); }