當前位置: 首頁>>代碼示例>>Java>>正文


Java Pipeline.eval方法代碼示例

本文整理匯總了Java中redis.clients.jedis.Pipeline.eval方法的典型用法代碼示例。如果您正苦於以下問題:Java Pipeline.eval方法的具體用法?Java Pipeline.eval怎麽用?Java Pipeline.eval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redis.clients.jedis.Pipeline的用法示例。


在下文中一共展示了Pipeline.eval方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testEvalKeyAndArg

import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Test
public void testEvalKeyAndArg() {
  String key = "test";
  String arg = "3";
  String script = "redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])";

  Pipeline p = jedis.pipelined();
  p.set(key, "0");
  Response<Object> result0 = p.eval(script, Arrays.asList(key), Arrays.asList(arg));
  p.incr(key);
  Response<Object> result1 = p.eval(script, Arrays.asList(key), Arrays.asList(arg));
  Response<String> result2 = p.get(key);
  p.sync();

  assertNull(result0.get());
  assertNull(result1.get());
  assertEquals("13", result2.get());
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:19,代碼來源:PipeliningTest.java

示例2: testEvalKeyAndArgWithBinary

import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Test
public void testEvalKeyAndArgWithBinary() {
  // binary
  byte[] bKey = SafeEncoder.encode("test");
  byte[] bArg = SafeEncoder.encode("3");
  byte[] bScript = SafeEncoder
      .encode("redis.call('INCRBY', KEYS[1], ARGV[1]) redis.call('INCRBY', KEYS[1], ARGV[1])");

  Pipeline bP = jedis.pipelined();
  bP.set(bKey, SafeEncoder.encode("0"));
  Response<Object> bResult0 = bP.eval(bScript, Arrays.asList(bKey), Arrays.asList(bArg));
  bP.incr(bKey);
  Response<Object> bResult1 = bP.eval(bScript, Arrays.asList(bKey), Arrays.asList(bArg));
  Response<byte[]> bResult2 = bP.get(bKey);
  bP.sync();

  assertNull(bResult0.get());
  assertNull(bResult1.get());
  assertArrayEquals(SafeEncoder.encode("13"), bResult2.get());
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:21,代碼來源:PipeliningTest.java

示例3: testEval

import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Test
public void testEval() {
  String script = "return 'success!'";

  Pipeline p = jedis.pipelined();
  Response<Object> result = p.eval(script);
  p.sync();

  assertEquals("success!", result.get());
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:11,代碼來源:PipeliningTest.java

示例4: testEvalWithBinary

import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Test
public void testEvalWithBinary() {
  String script = "return 'success!'";

  Pipeline p = jedis.pipelined();
  Response<Object> result = p.eval(SafeEncoder.encode(script));
  p.sync();

  assertArrayEquals(SafeEncoder.encode("success!"), (byte[]) result.get());
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:11,代碼來源:PipeliningTest.java

示例5: testEvalNestedLists

import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Test
public void testEvalNestedLists() {
  String script = "return { {KEYS[1]} , {2} }";

  Pipeline p = jedis.pipelined();
  Response<Object> result = p.eval(script, 1, "key1");
  p.sync();

  List<?> results = (List<?>) result.get();
  assertThat((List<String>) results.get(0), listWithItem("key1"));
  assertThat((List<Long>) results.get(1), listWithItem(2L));
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:13,代碼來源:PipeliningTest.java

示例6: testEvalNestedListsWithBinary

import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Test
public void testEvalNestedListsWithBinary() {
  byte[] bScript = SafeEncoder.encode("return { {KEYS[1]} , {2} }");
  byte[] bKey = SafeEncoder.encode("key1");

  Pipeline p = jedis.pipelined();
  Response<Object> result = p.eval(bScript, 1, bKey);
  p.sync();

  List<?> results = (List<?>) result.get();
  assertThat((List<byte[]>) results.get(0), listWithItem(bKey));
  assertThat((List<Long>) results.get(1), listWithItem(2L));
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:14,代碼來源:PipeliningTest.java

示例7: spushAndrpush

import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
private <T> void spushAndrpush(String setKey, String key, T... t) {
    String script = "redis.call('SADD',KEYS[1],ARGV[1]) if redis.call('LLEN',KEYS[2]) < redis.call('SCARD',KEYS[1]) then return redis.call('LPUSH',KEYS[2],ARGV[2]) end";
    String help = setKey + ":help";
    INaviMultiRedis multi = service.openPipeline(setKey);
    try {

        Pipeline pipe = multi.getPipeline();
        pipe.rpush(object2Bytes(key), objArray2BytesArray(t));
        pipe.eval(script, 2, new String[]{setKey, help, key, "HelpKey"});
        pipe.sync();
    } finally {
        multi.returnObject();
    }
}
 
開發者ID:sunguangran,項目名稱:navi,代碼行數:15,代碼來源:NaviRedisMutiKeyMessageQueue.java


注:本文中的redis.clients.jedis.Pipeline.eval方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。