Exemplo n.º 1
0
 @Test
 public void testScriptLoadAsync() {
   redisson.getBucket("foo").set("bar");
   Future<String> r = redisson.getScript().scriptLoadAsync("return redis.call('get', 'foo')");
   Assert.assertEquals(
       "282297a0228f48cd3fc6a55de6316f31422f5d17", r.awaitUninterruptibly().getNow());
   String r1 =
       redisson
           .getScript()
           .evalSha(
               Mode.READ_ONLY,
               "282297a0228f48cd3fc6a55de6316f31422f5d17",
               RScript.ReturnType.VALUE,
               Collections.emptyList());
   Assert.assertEquals("bar", r1);
 }
Exemplo n.º 2
0
  @Test
  public void testEvalshaAsync() {
    RScript s = redisson.getScript();
    String res = s.scriptLoad(null, "return redis.call('get', 'foo')");
    Assert.assertEquals("282297a0228f48cd3fc6a55de6316f31422f5d17", res);

    redisson.getBucket("foo").set("bar");
    String r =
        redisson
            .getScript()
            .eval(Mode.READ_ONLY, "return redis.call('get', 'foo')", RScript.ReturnType.VALUE);
    Assert.assertEquals("bar", r);
    Future<Object> r1 =
        redisson
            .getScript()
            .evalShaAsync(
                Mode.READ_ONLY,
                "282297a0228f48cd3fc6a55de6316f31422f5d17",
                RScript.ReturnType.VALUE,
                Collections.emptyList());
    Assert.assertEquals("bar", r1.awaitUninterruptibly().getNow());
  }