本文整理汇总了Java中redis.clients.jedis.ShardedJedis.exists方法的典型用法代码示例。如果您正苦于以下问题:Java ShardedJedis.exists方法的具体用法?Java ShardedJedis.exists怎么用?Java ShardedJedis.exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.ShardedJedis
的用法示例。
在下文中一共展示了ShardedJedis.exists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import redis.clients.jedis.ShardedJedis; //导入方法依赖的package包/类
public <K> K run(String key, Executor<K> executor, Integer... expire) {
ShardedJedis jedis = getJedis();
if (jedis == null) {
return null;
}
try {
K result = executor.execute(jedis);
if (jedis.exists(key)) {
if (expire == null || expire.length == 0) {
jedis.expire(key, EXPIRE);
} else if (expire.length == 1) {
jedis.expire(key, expire[0]);
}
}
return result;
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
if (jedis != null) {
jedis.close();
}
}
return null;
}
示例2: run
import redis.clients.jedis.ShardedJedis; //导入方法依赖的package包/类
public static <K> K run(String key, Executor<K> executor, Integer... expire) {
ShardedJedis jedis = getJedis();
if (jedis == null) {
return null;
}
try {
K result = executor.execute(jedis);
if (jedis.exists(key)) {
if (expire == null || expire.length == 0) {
jedis.expire(key, EXPIRE);
} else if (expire.length == 1) {
jedis.expire(key, expire[0]);
}
}
return result;
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
if (jedis != null) {
jedis.close();
}
}
return null;
}
示例3: exists
import redis.clients.jedis.ShardedJedis; //导入方法依赖的package包/类
@Override
public boolean exists(String key) {
ShardedJedis redis = null;
boolean isExists = false;
try {
redis = pool.getResource();
key = getKeyAll(key);
isExists = redis.exists(key);
return isExists;
} catch (RuntimeException e) {
if(redis != null ) {
pool.returnBrokenResource(redis);
}
logger.error("redis exists(String key):", e);
return isExists;
} finally{
if(redis != null ) {
pool.returnResource(redis);
}
}
}
示例4: exists
import redis.clients.jedis.ShardedJedis; //导入方法依赖的package包/类
public Boolean exists(String key) {
Boolean result = false;
ShardedJedis shardedJedis = shardedJedisPool.getResource();
if (shardedJedis == null) {
return false;
}
try {
result = shardedJedis.exists(key);
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
shardedJedis.close();
}
return result;
}