Example usage for org.springframework.data.redis.connection RedisConnection ttl

List of usage examples for org.springframework.data.redis.connection RedisConnection ttl

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection RedisConnection ttl.

Prototype

@Nullable
Long ttl(byte[] key);

Source Link

Document

Get the time to live for key in seconds.

Usage

From source file:com.zxy.commons.cache.RedisUtils.java

/**
 * Get the time to live for {@code key} in seconds.
 * <p>/*from w  w w  .j  ava 2 s.  c o  m*/
 * See http://redis.io/commands/ttl
 * 
 * @param key key
 * @return Long
 */
public static Long ttl(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.ttl(key);
        }
    });
}

From source file:com.zxy.commons.cache.RedisHelper.java

/**
 * Get the time to live for {@code key} in seconds.
 * <p>//from   w  w  w. j a va  2s  .co  m
 * See http://redis.io/commands/ttl
 * 
 * @param key key
 * @return Long
 */
public Long ttl(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.ttl(key);
        }
    });
}