本文整理了Java中redis.clients.jedis.JedisCluster.ttl()
方法的一些代码示例,展示了JedisCluster.ttl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JedisCluster.ttl()
方法的具体详情如下:
包路径:redis.clients.jedis.JedisCluster
类名称:JedisCluster
方法名:ttl
暂无
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Long ttl(byte[] key) {
Assert.notNull(key, "Key must not be null!");
try {
return connection.getCluster().ttl(key);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Long ttl(byte[] key, TimeUnit timeUnit) {
Assert.notNull(key, "Key must not be null!");
try {
return Converters.secondsToTimeUnit(connection.getCluster().ttl(key), timeUnit);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: hhfcyong/xxxx-dubbo
/**
* 以秒为单位,返回给定 key 的剩余生存时间(TTL, time to live)
* @param key
* @return key不存在:返回-2 key存在但没有设置生存时间:返回-1
*/
public long ttl(String key){
return jedisCluster.ttl(key);
}
/**
代码示例来源:origin: org.nutz/nutz-integration-jedis
public Long ttl(String key) {
return jedisCluster.ttl(key);
}
代码示例来源:origin: net.oschina.j2cache/j2cache-core
@Override
public Long ttl(byte[] bytes) {
return cluster.ttl(bytes);
}
代码示例来源:origin: org.nutz/nutz-integration-jedis
public Long ttl(byte[] key) {
return jedisCluster.ttl(key);
}
代码示例来源:origin: yangfuhai/jboot
/**
* 以秒为单位,返回给定 key 的剩余生存时间(TTL, time to live)。
*/
public Long ttl(Object key) {
return jedisCluster.ttl(keyToBytes(key));
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Long ttl(byte[] key) {
Assert.notNull(key, "Key must not be null!");
try {
return connection.getCluster().ttl(key);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: org.nanoframework/nano-orm-jedis
@Override
public long ttl(final String key) {
Assert.hasText(key);
try {
return cluster.ttl(key);
} catch (final Throwable e) {
throw new RedisClientException(e.getMessage(), e);
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long ttl(byte[] key) {
Assert.notNull(key, "Key must not be null!");
try {
return connection.getCluster().ttl(key);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Long ttl(byte[] key, TimeUnit timeUnit) {
Assert.notNull(key, "Key must not be null!");
try {
return Converters.secondsToTimeUnit(connection.getCluster().ttl(key), timeUnit);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Long ttl(byte[] key, TimeUnit timeUnit) {
Assert.notNull(key, "Key must not be null!");
try {
return Converters.secondsToTimeUnit(connection.getCluster().ttl(key), timeUnit);
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
}
代码示例来源:origin: yrain/smart-cache
/**
* 以秒为单位,返回给定 key 的剩余生存时间
* 不存在:-2
* 永久:-1
* 修改为:
* 永久:0
* 不存在:-1
*/
public Long ttl(Object key) {
if (null == key) {
return null;
}
long ttl = -2;
if (cluster) {
ttl = jedisCluster.ttl(serializeKey(key));
} else {
ttl = jedisOperator.ttl(serializeKey(key));
}
// 当 key 不存在时,返回 -2 。
if (ttl == -2) {
return -1l;
}
// 当 key 存在但没有设置剩余生存时间时,返回 -1
if (ttl == -1) {
return 0l;
}
return ttl;
}
内容来源于网络,如有侵权,请联系作者删除!