redis.clients.jedis.Jedis.eval()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(489)

本文整理了Java中redis.clients.jedis.Jedis.eval()方法的一些代码示例,展示了Jedis.eval()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.eval()方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:eval

Jedis.eval介绍

暂无

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
 public Object execute(Jedis connection) {
  return connection.eval(script);
 }
}.runBinary(key);

代码示例来源:origin: sohutv/cachecloud

@Override
 public Object execute(Jedis connection) {
  return connection.eval(script, keyCount, params);
 }
}.run(keyCount, params);

代码示例来源:origin: sohutv/cachecloud

@Override
 public Object execute(Jedis connection) {
  return connection.eval(script);
 }
}.run(key);

代码示例来源:origin: sohutv/cachecloud

@Override
 public Object execute(Jedis connection) {
  return connection.eval(script, keys, args);
 }
}.run(keys.size(), keys.toArray(new String[keys.size()]));

代码示例来源:origin: sohutv/cachecloud

@Override
 public Object execute(Jedis connection) {
  return connection.eval(script, keys, args);
 }
}.runBinary(keys.size(), keys.toArray(new byte[keys.size()][]));

代码示例来源:origin: sohutv/cachecloud

@Override
 public Object execute(Jedis connection) {
  return connection.eval(script, keyCount, params);
 }
}.runBinary(Integer.parseInt(SafeEncoder.encode(keyCount)), params);

代码示例来源:origin: sohutv/cachecloud

@Override
 public Object execute(Jedis connection) {
  return connection.eval(script, keyCount, params);
 }
}.runBinary(keyCount, params);

代码示例来源:origin: sohutv/cachecloud

@Override
public Object eval(String script) {
 return eval(script, 0);
}

代码示例来源:origin: sohutv/cachecloud

@Override
public Object eval(String script, List<String> keys, List<String> args) {
 return eval(script, keys.size(), getParams(keys, args));
}

代码示例来源:origin: changmingxie/tcc-transaction

@Override
  public Long doInJedis(Jedis jedis) {
    List<byte[]> params = new ArrayList<byte[]>();
    for (Map.Entry<byte[], byte[]> entry : ExpandTransactionSerializer.serialize(serializer, transaction).entrySet()) {
      params.add(entry.getKey());
      params.add(entry.getValue());
    }
    Object result = jedis.eval("if redis.call('exists', KEYS[1]) == 0 then redis.call('hmset', KEYS[1], unpack(ARGV)); return 1; end; return 0;".getBytes(),
        Arrays.asList(RedisHelper.getRedisKey(keyPrefix, transaction.getXid())), params);
    return (Long) result;
  }
});

代码示例来源:origin: changmingxie/tcc-transaction

@Override
  public Long doInJedis(Jedis jedis) {
    transaction.updateTime();
    transaction.updateVersion();
    List<byte[]> params = new ArrayList<byte[]>();
    for (Map.Entry<byte[], byte[]> entry : ExpandTransactionSerializer.serialize(serializer, transaction).entrySet()) {
      params.add(entry.getKey());
      params.add(entry.getValue());
    }
    Object result = jedis.eval(String.format("if redis.call('hget',KEYS[1],'VERSION') == '%s' then redis.call('hmset', KEYS[1], unpack(ARGV)); return 1; end; return 0;",
        transaction.getVersion() - 1).getBytes(),
        Arrays.asList(RedisHelper.getRedisKey(keyPrefix, transaction.getXid())), params);
    return (Long) result;
  }
});

代码示例来源:origin: sohutv/cachecloud

/**
 * 按内容执行脚本
 *
 * @param sha
 * @param key
 * @param args
 * @return
 */
public Object eval(String sha, String key, String... args) {
  SubPubClusterCommand subPubClusterCommand = new SubPubClusterCommand(this, connectionHandler, maxRedirections);
  Jedis jedis = subPubClusterCommand.getJedis(key);
  try {
    return jedis.eval(sha, 1, getKeys(key, args));
  } finally {
    if (jedis != null) {
      jedis.close();
    }
  }
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
@SuppressWarnings("unchecked")
public <T> T eval(byte[] script, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
  Assert.notNull(script, "Script must not be null!");
  if (isQueueing() || isPipelined()) {
    throw new UnsupportedOperationException();
  }
  try {
    return (T) new JedisScriptReturnConverter(returnType)
        .convert(connection.getJedis().eval(script, JedisConverters.toBytes(numKeys), keysAndArgs));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Map<RedisClusterNode, Collection<RedisClusterNode>> clusterGetMasterSlaveMap() {
  List<NodeResult<Collection<RedisClusterNode>>> nodeResults = clusterCommandExecutor
      .executeCommandAsyncOnNodes((JedisClusterCommandCallback<Collection<RedisClusterNode>>) client -> {
        // TODO: remove client.eval as soon as Jedis offers support for myid
        return JedisConverters.toSetOfRedisClusterNodes(
            client.clusterSlaves((String) client.eval("return redis.call('cluster', 'myid')", 0)));
      }, topologyProvider.getTopology().getActiveMasterNodes()).getResults();
  Map<RedisClusterNode, Collection<RedisClusterNode>> result = new LinkedHashMap<>();
  for (NodeResult<Collection<RedisClusterNode>> nodeResult : nodeResults) {
    result.put(nodeResult.getNode(), nodeResult.getValue());
  }
  return result;
}

代码示例来源:origin: Exrick/x-boot

void unlockRedisLock(String key,String value) {
  Jedis jedis = null;
  boolean broken = false;
  try {
    jedis = jedisPool.getResource();
    String luaScript=""
        +"\nlocal v = redis.call('GET', KEYS[1]);"
        +"\nlocal r= 0;"
        +"\nif v == ARGV[1] then"
        +"\nr =redis.call('DEL',KEYS[1]);"
        +"\nend"
        +"\nreturn r";
    List<String> keys = new ArrayList<String>();
    keys.add(key);
    List<String> args = new ArrayList<String>();
    args.add(value);
    Object r=jedis.eval(luaScript, keys, args);
  } finally {
    if(jedis!=null){
      jedis.close();
    }
  }
}

代码示例来源:origin: Exrick/x-boot

private String createRedisKey(String lockId) {
  Jedis jedis = null;
  boolean broken = false;
  try {
    String value=lockId+randomId(1);
    jedis = jedisPool.getResource();
    String luaScript = ""
        + "\nlocal r = tonumber(redis.call('SETNX', KEYS[1],ARGV[1]));"
        + "\nredis.call('PEXPIRE',KEYS[1],ARGV[2]);"
        + "\nreturn r";
    List<String> keys = new ArrayList<String>();
    keys.add(lockId);
    List<String> args = new ArrayList<String>();
    args.add(value);
    args.add(lockTimeout+"");
    Long ret = (Long) jedis.eval(luaScript, keys, args);
    if( new Long(1).equals(ret)){
      return value;
    }
  }finally {
    if(jedis!=null) {
      jedis.close();
    }
  }
  return null;
}

代码示例来源:origin: wangzheng0822/ratelimiter4j

@Override
public Object eval(String luaScript, String key, String params) {
 return execute((jedis) -> jedis.eval(luaScript, Lists.newArrayList(redisKeyPrefix + key),
   Lists.newArrayList(params)));
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Object eval(String script, int keyCount, String... params) {
 String command = "eval";
 return instrumented(command, payloadSize(script) + payloadSize(params), () -> delegated.eval(script, keyCount, params));
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Object eval(String script, List<String> keys, List<String> args) {
 String command = "eval";
 return instrumented(command, payloadSize(script) + payloadSize(args), () -> delegated.eval(script, keys, args));
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Object eval(byte[] script, List<byte[]> keys, List<byte[]> args) {
 String command = "eval";
 return instrumented(command, payloadSize(script) + payloadSize(args), () -> delegated.eval(script, keys, args));
}

相关文章

Jedis类方法