本文整理了Java中redis.clients.jedis.Jedis.scriptLoad()
方法的一些代码示例,展示了Jedis.scriptLoad()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.scriptLoad()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:scriptLoad
暂无
代码示例来源:origin: sohutv/cachecloud
@Override
public byte[] execute(Jedis connection) {
return connection.scriptLoad(script);
}
}.runBinary(key);
代码示例来源:origin: sohutv/cachecloud
@Override
public String execute(Jedis connection) {
return connection.scriptLoad(script);
}
}.run(key);
代码示例来源:origin: signalapp/Signal-Server
private String storeScript(ReplicatedJedisPool jedisPool, String script) {
try (Jedis jedis = jedisPool.getWriteResource()) {
return jedis.scriptLoad(script);
}
}
代码示例来源: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: sohutv/cachecloud
/**
* 将脚本script添加到集群所有节点缓存中
*
* @param script
* @return
*/
public String loadScruptAllNodes(String script) {
Map<String, JedisPool> nodeMap = getClusterNodes();
String md5 = null;
for (JedisPool jedisPool : nodeMap.values()) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
String returnMd5 = jedis.scriptLoad(script);
if (returnMd5 != null) {
md5 = returnMd5;
}
} finally {
if (jedis != null) {
jedis.close();
}
}
}
return md5;
}
代码示例来源: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: spring-projects/spring-data-redis
@Override
public String scriptLoad(byte[] script) {
Assert.notNull(script, "Script must not be null!");
if (isQueueing() || isPipelined()) {
throw new UnsupportedOperationException();
}
try {
return JedisConverters.toString(connection.getJedis().scriptLoad(script));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public String execute(Jedis connection) {
return connection.scriptLoad(script);
}
}.run(sampleKey);
代码示例来源:origin: apache/servicemix-bundles
@Override
public byte[] execute(Jedis connection) {
return connection.scriptLoad(script);
}
}.runBinary(sampleKey);
代码示例来源:origin: mindwind/craft-atom
private String scriptload0(Jedis j, String script) {
return j.scriptLoad(script);
}
代码示例来源:origin: gresrun/jesque
protected void loadRedisScripts(Jedis jedis) throws IOException {
popScriptHash.set(jedis.scriptLoad(ScriptUtils.readScript(POP_LUA)));
lpoplpushScriptHash.set(jedis.scriptLoad(ScriptUtils.readScript(LPOPLPUSH_LUA)));
multiPriorityQueuesScriptHash.set(jedis.scriptLoad(ScriptUtils.readScript(POP_FROM_MULTIPLE_PRIO_QUEUES)));
}
代码示例来源:origin: gresrun/jesque
private void loadRedisScripts() throws IOException {
this.popScriptHash.set(this.jedis.scriptLoad(ScriptUtils.readScript(POP_LUA)));
this.lpoplpushScriptHash.set(this.jedis.scriptLoad(ScriptUtils.readScript(LPOPLPUSH_LUA)));
this.multiPriorityQueuesScriptHash
.set(this.jedis.scriptLoad(ScriptUtils.readScript(POP_FROM_MULTIPLE_PRIO_QUEUES)));
}
代码示例来源:origin: Baqend/Orestes-Bloomfilter
/**
* Load a Lua script into Redis.
*
* @param filename The filename of the script.
* @return A handle to the loaded script.
*/
protected String loadLuaScript(String filename) {
InputStream stream = AbstractExpiringBloomFilterRedis.class.getResourceAsStream(filename);
String script = new BufferedReader(new InputStreamReader(stream)).lines().collect(Collectors.joining("\n"));
return pool.safelyReturn(jedis -> jedis.scriptLoad(script));
}
代码示例来源:origin: ysrc/Liudao
@Override
public Object doInRedis(RedisConnection connection) throws DataAccessException {
return ((Jedis) connection.getNativeConnection()).scriptLoad(script);
}
});
代码示例来源:origin: org.nutz/nutz-integration-jedis
public String scriptLoad(String script) {
Jedis jedis = getJedis();
try {
return jedis.scriptLoad(script);
} finally {Streams.safeClose(jedis);}
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public String scriptLoad(String script) {
String command = "scriptLoad";
return instrumented(command, payloadSize(script), () -> delegated.scriptLoad(script));
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public byte[] scriptLoad(byte[] script) {
String command = "scriptLoad";
return instrumented(command, payloadSize(script), () -> delegated.scriptLoad(script));
}
代码示例来源:origin: org.nutz/nutz-integration-jedis
public byte[] scriptLoad(byte[] script) {
Jedis jedis = getJedis();
try {
return jedis.scriptLoad(script);
} finally {Streams.safeClose(jedis);}
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public String scriptLoad(byte[] script) {
Assert.notNull(script, "Script must not be null!");
if (isQueueing() || isPipelined()) {
throw new UnsupportedOperationException();
}
try {
return JedisConverters.toString(connection.getJedis().scriptLoad(script));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
内容来源于网络,如有侵权,请联系作者删除!