本文整理了Java中redis.clients.jedis.Jedis.evalsha()
方法的一些代码示例,展示了Jedis.evalsha()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.evalsha()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:evalsha
暂无
代码示例来源:origin: sohutv/cachecloud
@Override
public Object execute(Jedis connection) {
return connection.evalsha(sha1, keys, args);
}
}.run(keys.size(), keys.toArray(new String[keys.size()]));
代码示例来源:origin: sohutv/cachecloud
@Override
public Object execute(Jedis connection) {
return connection.evalsha(sha1, keys, args);
}
}.runBinary(keys.size(), keys.toArray(new byte[keys.size()][]));
代码示例来源:origin: sohutv/cachecloud
@Override
public Object execute(Jedis connection) {
return connection.evalsha(sha1, keyCount, params);
}
}.runBinary(keyCount, params);
代码示例来源:origin: sohutv/cachecloud
@Override
public Object execute(Jedis connection) {
return connection.evalsha(sha1, keyCount, params);
}
}.run(keyCount, params);
代码示例来源:origin: sohutv/cachecloud
@Override
public Object execute(Jedis connection) {
return connection.evalsha(script);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public Object execute(Jedis connection) {
return connection.evalsha(script);
}
}.run(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public Object evalsha(String script) {
return evalsha(script, 0);
}
代码示例来源:origin: sohutv/cachecloud
@Override
public Object evalsha(String sha1, List<String> keys, List<String> args) {
return evalsha(sha1, keys.size(), getParams(keys, args));
}
代码示例来源:origin: signalapp/Signal-Server
public Object execute(List<byte[]> keys, List<byte[]> args) {
try (Jedis jedis = jedisPool.getWriteResource()) {
try {
return jedis.evalsha(sha, keys, args);
} catch (JedisDataException e) {
storeScript(jedisPool, script);
return jedis.evalsha(sha, keys, args);
}
}
}
代码示例来源:origin: qiurunze123/miaosha
/**
* 未完成 需 evalsha更方便 限制ip 或者 手机号访问次数
*/
public static void getLuaLimit() {
Jedis jedis = null;
try {
jedis = RedisManager.getJedis();
} catch (Exception e) {
e.printStackTrace();
}
String lua =
"local num=redis.call('incr',KEYS[1]) if tonumber(num)==1 " +
"then redis.call('expire',KEYS[1],ARGV[1]) " +
"return 1 elseif tonumber(num)>" +
"tonumber(ARGV[2]) then return 0 else return 1 end";
List<String> keys = new ArrayList<String>();
keys.add("ip:limit:127.0.0.1");
List<String> argves = new ArrayList<String>();
argves.add("6000");
argves.add("5");
jedis.auth("xxxx");
// Object evalSha = jedis.evalsha(lua);
String luaScript = jedis.scriptLoad(lua);
System.out.println(luaScript);
Object object = jedis.evalsha(luaScript, keys, argves);
System.out.println(object);
}
代码示例来源:origin: qiurunze123/miaosha
/**
* 统计访问次数
*/
public static void vistorCount(String key) {
Jedis jedis = null;
Object object = null;
try {
jedis = RedisManager.getJedis();
String count =
"local num=redis.call('incr',KEYS[1]) return num";
List<String> keys = new ArrayList<String>();
keys.add(key);
List<String> argves = new ArrayList<String>();
jedis.auth("youxin11");
String luaScript = jedis.scriptLoad(count);
System.out.println(luaScript);
jedis.evalsha(luaScript, keys, argves);
} catch (Exception e) {
logger.error("统计访问次数失败!!!",e);
}
}
}
代码示例来源:origin: qiurunze123/miaosha
/**
* 统计访问次数
*/
public static Object getVistorCount(String key) {
Jedis jedis = null;
Object object = null;
try {
jedis = RedisManager.getJedis();
String count =
"local num=redis.call('get',KEYS[1]) return num";
List<String> keys = new ArrayList<String>();
keys.add(key);
List<String> argves = new ArrayList<String>();
jedis.auth("youxin11");
String luaScript = jedis.scriptLoad(count);
System.out.println(luaScript);
object = jedis.evalsha(luaScript, keys, argves);
} catch (Exception e) {
logger.error("统计访问次数失败!!!",e);
return "0";
}
return object;
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
@SuppressWarnings("unchecked")
public <T> T evalSha(byte[] scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
Assert.notNull(scriptSha1, "Script digest must not be null!");
if (isQueueing() || isPipelined()) {
throw new UnsupportedOperationException();
}
try {
return (T) new JedisScriptReturnConverter(returnType)
.convert(connection.getJedis().evalsha(scriptSha1, numKeys, keysAndArgs));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: sohutv/cachecloud
/**
* 按校验和执行脚本
*
* @param sha
* @param key
* @param args
* @return
*/
public Object evalsha(String sha, String key, String... args) {
SubPubClusterCommand subPubClusterCommand = new SubPubClusterCommand(this, connectionHandler, maxRedirections);
Jedis jedis = subPubClusterCommand.getJedis(key);
try {
return jedis.evalsha(sha, 1, getKeys(key, args));
} finally {
if (jedis != null) {
jedis.close();
}
}
}
代码示例来源:origin: ysrc/Liudao
@Override
public Object doInRedis(RedisConnection connection) throws DataAccessException {
return ((Jedis) connection.getNativeConnection()).evalsha(sha, keycount, args);
}
});
代码示例来源:origin: Baqend/Orestes-Bloomfilter
@Override
public void reportRead(T element, long TTL, TimeUnit unit) {
try (Jedis jedis = pool.getResource()) {
// Create timestamp from TTL
long timestamp = remainingTTLToScore(TTL, unit);
jedis.evalsha(reportReadScript, 1, keys.TTL_KEY, String.valueOf(timestamp), element.toString());
}
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public Object evalsha(String sha1, List<String> keys, List<String> args) {
String command = "evalsha";
return instrumented(command, payloadSize(args), () -> delegated.evalsha(sha1, keys, args));
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public Object evalsha(String sha1, int keyCount, String... params) {
String command = "evalsha";
return instrumented(command, payloadSize(params), () -> delegated.evalsha(sha1, keyCount, params));
}
代码示例来源:origin: org.nutz/nutz-integration-jedis
public Object evalsha(String script) {
Jedis jedis = getJedis();
try {
return jedis.evalsha(script);
} finally {Streams.safeClose(jedis);}
}
代码示例来源:origin: org.nutz/nutz-integration-jedis
public Object evalsha(String sha1, int keyCount, String... params) {
Jedis jedis = getJedis();
try {
return jedis.evalsha(sha1, keyCount, params);
} finally {Streams.safeClose(jedis);}
}
内容来源于网络,如有侵权,请联系作者删除!