本文整理匯總了Java中redis.clients.jedis.Jedis.eval方法的典型用法代碼示例。如果您正苦於以下問題:Java Jedis.eval方法的具體用法?Java Jedis.eval怎麽用?Java Jedis.eval使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.Jedis
的用法示例。
在下文中一共展示了Jedis.eval方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: eval
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
/**
* Eval lua script command
*
* @param script
* @param keys
* @param args
* @return
*/
public Object eval(String script, List<String> keys, List<String> args) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.eval(script, keys, args);
} finally {
if (jedis != null) {
jedis.close();
}
}
}
示例2: putMultiIfNotExists
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public boolean putMultiIfNotExists(String cacheKey1, Object obj1, String cacheKey2, Object obj2) {
Jedis jedis = null;
try {
jedis = pool.getResource();
List<byte[]> keys = new ArrayList<>(2);
keys.add(cacheKey1.getBytes());
keys.add(cacheKey2.getBytes());
List<byte[]> args = new ArrayList<>(2);
args.add(getBytes(obj1));
args.add(getBytes(obj2));
Long response = (Long) jedis.eval(DOUBLE_LOCK_SCRIPT, keys, args);
pool.returnResource(jedis);
return response == 1;
} catch (Exception e) {
LOGGER.warn("Failed to put key in cache {0}", cacheKey1, e);
pool.returnBrokenResource(jedis);
}
return false;
}
示例3: deleteByPattern
import redis.clients.jedis.Jedis; //導入方法依賴的package包/類
@Override
public void deleteByPattern(String pattern) {
Jedis jedis = null;
try {
jedis = pool.getResource();
jedis.eval(String.format(DELETE_SCRIPT_IN_LUA, pattern));
pool.returnResource(jedis);
} catch (Exception e) {
LOGGER.warn("Failed to delete multiple pattern from cache {0}", pattern, e);
pool.returnBrokenResource(jedis);
}
}