Java 类redis.clients.jedis.Protocol.Keyword 实例源码

项目:JRediClients    文件:ScanParams.java   
public Collection<byte[]> getParams() {
    List<byte[]> paramsList = new ArrayList<byte[]>(params.size());
    for (Map.Entry<Keyword, ByteBuffer> param : params.entrySet()) {
        paramsList.add(param.getKey().raw);
        paramsList.add(param.getValue().array());
    }
    return Collections.unmodifiableCollection(paramsList);
}
项目:JRediClients    文件:TransactionCommandsTest.java   
@Test
public void unwatch() throws UnknownHostException, IOException {
  jedis.watch("mykey");
  String val = jedis.get("mykey");
  val = "foo";
  String status = jedis.unwatch();
  assertEquals("OK", status);
  Transaction t = jedis.multi();

  nj.connect();
  nj.auth("foobared");
  nj.set("mykey", "bar");
  nj.disconnect();

  t.set("mykey", val);
  List<Object> resp = t.exec();
  assertEquals(1, resp.size());
  assertEquals("OK", resp.get(0));

  // Binary
  jedis.watch(bmykey);
  byte[] bval = jedis.get(bmykey);
  bval = bfoo;
  status = jedis.unwatch();
  assertEquals(Keyword.OK.name(), status);
  t = jedis.multi();

  nj.connect();
  nj.auth("foobared");
  nj.set(bmykey, bbar);
  nj.disconnect();

  t.set(bmykey, bval);
  resp = t.exec();
  assertEquals(1, resp.size());
  assertEquals("OK", resp.get(0));
}
项目:JRediClients    文件:AllKindOfValuesCommandsTest.java   
@Test
public void psetex() {
  long pttl = jedis.pttl("foo");
  assertEquals(-2, pttl);

  String status = jedis.psetex("foo", 200000000000L, "bar");
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));

  pttl = jedis.pttl("foo");
  assertTrue(pttl > 100000000000L);
}
项目:JRediClients    文件:AllKindOfValuesCommandsTest.java   
@Test
public void setNxExAndGet() {
  String status = jedis.set("hello", "world", "NX", "EX", expireSeconds);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  String value = jedis.get("hello");
  assertEquals("world", value);

  jedis.set("hello", "bar", "NX", "EX", expireSeconds);
  value = jedis.get("hello");
  assertEquals("world", value);

  long ttl = jedis.ttl("hello");
  assertTrue(ttl > 0 && ttl <= expireSeconds);

  // binary
  byte[] bworld = { 0x77, 0x6F, 0x72, 0x6C, 0x64 };
  byte[] bhello = { 0x68, 0x65, 0x6C, 0x6C, 0x6F };
  String bstatus = jedis.set(bworld, bhello, bnx, bex, expireSeconds);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(bstatus));
  byte[] bvalue = jedis.get(bworld);
  assertTrue(Arrays.equals(bhello, bvalue));

  jedis.set(bworld, bbar, bnx, bex, expireSeconds);
  bvalue = jedis.get(bworld);
  assertTrue(Arrays.equals(bhello, bvalue));

  long bttl = jedis.ttl(bworld);
  assertTrue(bttl > 0 && bttl <= expireSeconds);
}
项目:JRediClients    文件:BinaryValuesCommandsTest.java   
@Test
public void setAndGet() {
  String status = jedis.set(bfoo, binaryValue);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));

  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:JRediClients    文件:BinaryValuesCommandsTest.java   
@Test
public void setNxExAndGet() {
  String status = jedis.set(bfoo, binaryValue, bnx, bex, expireSeconds);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:JRediClients    文件:BinaryValuesCommandsTest.java   
@Test
public void setIfNotExistAndGet() {
  String status = jedis.set(bfoo, binaryValue);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  // nx should fail if value exists
  String statusFail = jedis.set(bfoo, binaryValue, bnx, bex, expireSeconds);
  assertNull(statusFail);

  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:JRediClients    文件:BinaryValuesCommandsTest.java   
@Test
public void setIfExistAndGet() {
  String status = jedis.set(bfoo, binaryValue);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  // nx should fail if value exists
  String statusSuccess = jedis.set(bfoo, binaryValue, bxx, bex, expireSeconds);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(statusSuccess));

  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:JRediClients    文件:BinaryValuesCommandsTest.java   
@Test
public void setAndExpireMillis() {
  String status = jedis.set(bfoo, binaryValue, bnx, bpx, expireMillis);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  long ttl = jedis.ttl(bfoo);
  assertTrue(ttl > 0 && ttl <= expireSeconds);
}
项目:JRediClients    文件:BinaryValuesCommandsTest.java   
@Test
public void setAndExpire() {
  String status = jedis.set(bfoo, binaryValue, bnx, bex, expireSeconds);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  long ttl = jedis.ttl(bfoo);
  assertTrue(ttl > 0 && ttl <= expireSeconds);
}
项目:JRediClients    文件:BinaryValuesCommandsTest.java   
@Test
public void setex() {
  String status = jedis.setex(bfoo, 20, binaryValue);
  assertEquals(Keyword.OK.name(), status);
  long ttl = jedis.ttl(bfoo);
  assertTrue(ttl > 0 && ttl <= 20);
}
项目:JRediClients    文件:BinaryValuesCommandsTest.java   
@Test
public void mset() {
  String status = jedis.mset(bfoo, binaryValue, bbar, bfoo);
  assertEquals(Keyword.OK.name(), status);
  assertTrue(Arrays.equals(binaryValue, jedis.get(bfoo)));
  assertTrue(Arrays.equals(bfoo, jedis.get(bbar)));
}
项目:x7    文件:BinaryClient.java   
public void scriptExists(byte[]... sha1) {
  byte[][] args = new byte[sha1.length + 1][];
  args[0] = Keyword.EXISTS.raw;
  for (int i = 0; i < sha1.length; i++)
    args[i + 1] = sha1[i];

  sendCommand(SCRIPT, args);
}
项目:x7    文件:BinaryClient.java   
public void bitop(BitOP op, byte[] destKey, byte[]... srcKeys) {
  Keyword kw = Keyword.AND;
  int len = srcKeys.length;
  switch (op) {
  case AND:
    kw = Keyword.AND;
    break;
  case OR:
    kw = Keyword.OR;
    break;
  case XOR:
    kw = Keyword.XOR;
    break;
  case NOT:
    kw = Keyword.NOT;
    len = Math.min(1, len);
    break;
  }

  byte[][] bargs = new byte[len + 2][];
  bargs[0] = kw.raw;
  bargs[1] = destKey;
  for (int i = 0; i < len; ++i) {
    bargs[i + 2] = srcKeys[i];
  }

  sendCommand(BITOP, bargs);
}
项目:cachecloud    文件:BinaryClient.java   
public void scriptExists(byte[]... sha1) {
  byte[][] args = new byte[sha1.length + 1][];
  args[0] = Keyword.EXISTS.raw;
  for (int i = 0; i < sha1.length; i++)
    args[i + 1] = sha1[i];

  sendCommand(SCRIPT, args);
}
项目:cachecloud    文件:BinaryClient.java   
public void bitop(BitOP op, byte[] destKey, byte[]... srcKeys) {
  Keyword kw = Keyword.AND;
  int len = srcKeys.length;
  switch (op) {
  case AND:
    kw = Keyword.AND;
    break;
  case OR:
    kw = Keyword.OR;
    break;
  case XOR:
    kw = Keyword.XOR;
    break;
  case NOT:
    kw = Keyword.NOT;
    len = Math.min(1, len);
    break;
  }

  byte[][] bargs = new byte[len + 2][];
  bargs[0] = kw.raw;
  bargs[1] = destKey;
  for (int i = 0; i < len; ++i) {
    bargs[i + 2] = srcKeys[i];
  }

  sendCommand(BITOP, bargs);
}
项目:cachecloud    文件:TransactionCommandsTest.java   
@Test
public void unwatch() throws UnknownHostException, IOException {
  jedis.watch("mykey");
  String val = jedis.get("mykey");
  val = "foo";
  String status = jedis.unwatch();
  assertEquals("OK", status);
  Transaction t = jedis.multi();

  nj.connect();
  nj.auth("foobared");
  nj.set("mykey", "bar");
  nj.disconnect();

  t.set("mykey", val);
  List<Object> resp = t.exec();
  assertEquals(1, resp.size());
  assertEquals("OK", resp.get(0));

  // Binary
  jedis.watch(bmykey);
  byte[] bval = jedis.get(bmykey);
  bval = bfoo;
  status = jedis.unwatch();
  assertEquals(Keyword.OK.name(), status);
  t = jedis.multi();

  nj.connect();
  nj.auth("foobared");
  nj.set(bmykey, bbar);
  nj.disconnect();

  t.set(bmykey, bval);
  resp = t.exec();
  assertEquals(1, resp.size());
  assertEquals("OK", resp.get(0));
}
项目:cachecloud    文件:AllKindOfValuesCommandsTest.java   
@Test
public void psetex() {
  long pttl = jedis.pttl("foo");
  assertEquals(-2, pttl);

  String status = jedis.psetex("foo", 200000000000L, "bar");
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));

  pttl = jedis.pttl("foo");
  assertTrue(pttl > 100000000000L);
}
项目:cachecloud    文件:AllKindOfValuesCommandsTest.java   
@Test
public void setNxExAndGet() {
  String status = jedis.set("hello", "world", setParams().nx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  String value = jedis.get("hello");
  assertEquals("world", value);

  jedis.set("hello", "bar", setParams().nx().ex(expireSeconds));
  value = jedis.get("hello");
  assertEquals("world", value);

  long ttl = jedis.ttl("hello");
  assertTrue(ttl > 0 && ttl <= expireSeconds);

  // binary
  byte[] bworld = { 0x77, 0x6F, 0x72, 0x6C, 0x64 };
  byte[] bhello = { 0x68, 0x65, 0x6C, 0x6C, 0x6F };

  String bstatus = jedis.set(bworld, bhello, setParams().nx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(bstatus));
  byte[] bvalue = jedis.get(bworld);
  assertTrue(Arrays.equals(bhello, bvalue));

  jedis.set(bworld, bbar, setParams().nx().ex(expireSeconds));
  bvalue = jedis.get(bworld);
  assertTrue(Arrays.equals(bhello, bvalue));

  long bttl = jedis.ttl(bworld);
  assertTrue(bttl > 0 && bttl <= expireSeconds);
}
项目:cachecloud    文件:BinaryValuesCommandsTest.java   
@Test
public void setAndGet() {
  String status = jedis.set(bfoo, binaryValue);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));

  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:cachecloud    文件:BinaryValuesCommandsTest.java   
@Test
public void setNxExAndGet() {
  String status = jedis.set(bfoo, binaryValue, setParams().nx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:cachecloud    文件:BinaryValuesCommandsTest.java   
@Test
public void setIfNotExistAndGet() {
  String status = jedis.set(bfoo, binaryValue);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  // nx should fail if value exists
  String statusFail = jedis.set(bfoo, binaryValue, setParams().nx().ex(expireSeconds));
  assertNull(statusFail);

  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:cachecloud    文件:BinaryValuesCommandsTest.java   
@Test
public void setIfExistAndGet() {
  String status = jedis.set(bfoo, binaryValue);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  // nx should fail if value exists
  String statusSuccess = jedis.set(bfoo, binaryValue, setParams().xx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(statusSuccess));

  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:cachecloud    文件:BinaryValuesCommandsTest.java   
@Test
public void setAndExpireMillis() {
  String status = jedis.set(bfoo, binaryValue, setParams().nx().px(expireMillis));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  long ttl = jedis.ttl(bfoo);
  assertTrue(ttl > 0 && ttl <= expireSeconds);
}
项目:cachecloud    文件:BinaryValuesCommandsTest.java   
@Test
public void setAndExpire() {
  String status = jedis.set(bfoo, binaryValue, setParams().nx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  long ttl = jedis.ttl(bfoo);
  assertTrue(ttl > 0 && ttl <= expireSeconds);
}
项目:cachecloud    文件:BinaryValuesCommandsTest.java   
@Test
public void setex() {
  String status = jedis.setex(bfoo, 20, binaryValue);
  assertEquals(Keyword.OK.name(), status);
  long ttl = jedis.ttl(bfoo);
  assertTrue(ttl > 0 && ttl <= 20);
}
项目:cachecloud    文件:BinaryValuesCommandsTest.java   
@Test
public void mset() {
  String status = jedis.mset(bfoo, binaryValue, bbar, bfoo);
  assertEquals(Keyword.OK.name(), status);
  assertTrue(Arrays.equals(binaryValue, jedis.get(bfoo)));
  assertTrue(Arrays.equals(bfoo, jedis.get(bbar)));
}
项目:Jedis    文件:BinaryClient.java   
public void scriptExists(byte[]... sha1) {
  byte[][] args = new byte[sha1.length + 1][];
  args[0] = Keyword.EXISTS.raw;
  for (int i = 0; i < sha1.length; i++)
    args[i + 1] = sha1[i];

  sendCommand(SCRIPT, args);
}
项目:Jedis    文件:BinaryClient.java   
public void bitop(BitOP op, byte[] destKey, byte[]... srcKeys) {
  Keyword kw = Keyword.AND;
  int len = srcKeys.length;
  switch (op) {
  case AND:
    kw = Keyword.AND;
    break;
  case OR:
    kw = Keyword.OR;
    break;
  case XOR:
    kw = Keyword.XOR;
    break;
  case NOT:
    kw = Keyword.NOT;
    len = Math.min(1, len);
    break;
  }

  byte[][] bargs = new byte[len + 2][];
  bargs[0] = kw.raw;
  bargs[1] = destKey;
  for (int i = 0; i < len; ++i) {
    bargs[i + 2] = srcKeys[i];
  }

  sendCommand(BITOP, bargs);
}
项目:Jedis    文件:TransactionCommandsTest.java   
@Test
public void unwatch() throws UnknownHostException, IOException {
  jedis.watch("mykey");
  String val = jedis.get("mykey");
  val = "foo";
  String status = jedis.unwatch();
  assertEquals("OK", status);
  Transaction t = jedis.multi();

  nj.connect();
  nj.auth("foobared");
  nj.set("mykey", "bar");
  nj.disconnect();

  t.set("mykey", val);
  List<Object> resp = t.exec();
  assertEquals(1, resp.size());
  assertEquals("OK", resp.get(0));

  // Binary
  jedis.watch(bmykey);
  byte[] bval = jedis.get(bmykey);
  bval = bfoo;
  status = jedis.unwatch();
  assertEquals(Keyword.OK.name(), status);
  t = jedis.multi();

  nj.connect();
  nj.auth("foobared");
  nj.set(bmykey, bbar);
  nj.disconnect();

  t.set(bmykey, bval);
  resp = t.exec();
  assertEquals(1, resp.size());
  assertEquals("OK", resp.get(0));
}
项目:Jedis    文件:AllKindOfValuesCommandsTest.java   
@Test
public void psetex() {
  long pttl = jedis.pttl("foo");
  assertEquals(-2, pttl);

  String status = jedis.psetex("foo", 200000000000L, "bar");
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));

  pttl = jedis.pttl("foo");
  assertTrue(pttl > 100000000000L);
}
项目:Jedis    文件:AllKindOfValuesCommandsTest.java   
@Test
public void setNxExAndGet() {
  String status = jedis.set("hello", "world", setParams().nx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  String value = jedis.get("hello");
  assertEquals("world", value);

  jedis.set("hello", "bar", setParams().nx().ex(expireSeconds));
  value = jedis.get("hello");
  assertEquals("world", value);

  long ttl = jedis.ttl("hello");
  assertTrue(ttl > 0 && ttl <= expireSeconds);

  // binary
  byte[] bworld = { 0x77, 0x6F, 0x72, 0x6C, 0x64 };
  byte[] bhello = { 0x68, 0x65, 0x6C, 0x6C, 0x6F };

  String bstatus = jedis.set(bworld, bhello, setParams().nx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(bstatus));
  byte[] bvalue = jedis.get(bworld);
  assertTrue(Arrays.equals(bhello, bvalue));

  jedis.set(bworld, bbar, setParams().nx().ex(expireSeconds));
  bvalue = jedis.get(bworld);
  assertTrue(Arrays.equals(bhello, bvalue));

  long bttl = jedis.ttl(bworld);
  assertTrue(bttl > 0 && bttl <= expireSeconds);
}
项目:Jedis    文件:BinaryValuesCommandsTest.java   
@Test
public void setAndGet() {
  String status = jedis.set(bfoo, binaryValue);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));

  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:Jedis    文件:BinaryValuesCommandsTest.java   
@Test
public void setNxExAndGet() {
  String status = jedis.set(bfoo, binaryValue, setParams().nx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:Jedis    文件:BinaryValuesCommandsTest.java   
@Test
public void setIfNotExistAndGet() {
  String status = jedis.set(bfoo, binaryValue);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  // nx should fail if value exists
  String statusFail = jedis.set(bfoo, binaryValue, setParams().nx().ex(expireSeconds));
  assertNull(statusFail);

  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:Jedis    文件:BinaryValuesCommandsTest.java   
@Test
public void setIfExistAndGet() {
  String status = jedis.set(bfoo, binaryValue);
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  // nx should fail if value exists
  String statusSuccess = jedis.set(bfoo, binaryValue, setParams().xx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(statusSuccess));

  byte[] value = jedis.get(bfoo);
  assertTrue(Arrays.equals(binaryValue, value));

  assertNull(jedis.get(bbar));
}
项目:Jedis    文件:BinaryValuesCommandsTest.java   
@Test
public void setAndExpireMillis() {
  String status = jedis.set(bfoo, binaryValue, setParams().nx().px(expireMillis));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  long ttl = jedis.ttl(bfoo);
  assertTrue(ttl > 0 && ttl <= expireSeconds);
}
项目:Jedis    文件:BinaryValuesCommandsTest.java   
@Test
public void setAndExpire() {
  String status = jedis.set(bfoo, binaryValue, setParams().nx().ex(expireSeconds));
  assertTrue(Keyword.OK.name().equalsIgnoreCase(status));
  long ttl = jedis.ttl(bfoo);
  assertTrue(ttl > 0 && ttl <= expireSeconds);
}
项目:Jedis    文件:BinaryValuesCommandsTest.java   
@Test
public void setex() {
  String status = jedis.setex(bfoo, 20, binaryValue);
  assertEquals(Keyword.OK.name(), status);
  long ttl = jedis.ttl(bfoo);
  assertTrue(ttl > 0 && ttl <= 20);
}
项目:Jedis    文件:BinaryValuesCommandsTest.java   
@Test
public void mset() {
  String status = jedis.mset(bfoo, binaryValue, bbar, bfoo);
  assertEquals(Keyword.OK.name(), status);
  assertTrue(Arrays.equals(binaryValue, jedis.get(bfoo)));
  assertTrue(Arrays.equals(bfoo, jedis.get(bbar)));
}