Example usage for org.springframework.data.redis.core RedisCallback RedisCallback

List of usage examples for org.springframework.data.redis.core RedisCallback RedisCallback

Introduction

In this page you can find the example usage for org.springframework.data.redis.core RedisCallback RedisCallback.

Prototype

RedisCallback

Source Link

Usage

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

/**
 * Set time to live for given {@code key} in milliseconds.
 * <p>/* www .j  a va 2 s .  com*/
 * See http://redis.io/commands/pexpire
 * 
 * @param key key
 * @param millis millis
 * @return Boolean
 */
public Boolean pExpire(byte[] key, long millis) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.pExpire(key, millis);
        }
    });
}

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

/**
 * Set the expiration for given {@code key} as a {@literal UNIX} timestamp in milliseconds.
 * <p>/* w  w  w. j a  v a  2 s .  c  o  m*/
 * See http://redis.io/commands/pexpireat
 * 
 * @param key key
 * @param unixTimeInMillis unixTimeInMillis
 * @return Boolean
 */
public static Boolean pExpireAt(byte[] key, long unixTimeInMillis) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.pExpireAt(key, unixTimeInMillis);
        }
    });
}

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

/**
 * Set the expiration for given {@code key} as a {@literal UNIX} timestamp.
 * <p>/*from   w  w w  . java2  s  .  c  om*/
 * See http://redis.io/commands/expireat
 * 
 * @param key key
 * @param unixTime unixTime
 * @return Boolean
 */
public Boolean expireAt(byte[] key, long unixTime) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.expireAt(key, unixTime);
        }
    });
}

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

/**
 * Remove the expiration from given {@code key}.
 * <p>//from   ww w .  j ava 2  s  .  c o  m
 * See http://redis.io/commands/persist
 * 
 * @param key key
 * @return Boolean
 */
public static Boolean persist(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.persist(key);
        }
    });
}

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

/**
 * Set the expiration for given {@code key} as a {@literal UNIX} timestamp in milliseconds.
 * <p>// w  ww. j  av a  2 s.  c o m
 * See http://redis.io/commands/pexpireat
 * 
 * @param key key
 * @param unixTimeInMillis unixTimeInMillis
 * @return Boolean
 */
public Boolean pExpireAt(byte[] key, long unixTimeInMillis) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.pExpireAt(key, unixTimeInMillis);
        }
    });
}

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

/**
 * Move given {@code key} to database with {@code index}.
 * <p>//from   w  w w.j  a  v a 2s  .  c o  m
 * See http://redis.io/commands/move
 * 
 * @param key key
 * @param dbIndex dbIndex
 * @return Boolean
 */
public static Boolean move(byte[] key, int dbIndex) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.move(key, dbIndex);
        }
    });
}

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

/**
 * Remove the expiration from given {@code key}.
 * <p>/*from   w ww. j a v a  2 s  .com*/
 * See http://redis.io/commands/persist
 * 
 * @param key key
 * @return Boolean
 */
public Boolean persist(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.persist(key);
        }
    });
}

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

/**
 * Get the time to live for {@code key} in seconds.
 * <p>/* ww w  . j  av  a  2 s . co 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

/**
 * Move given {@code key} to database with {@code index}.
 * <p>//from   w w w.ja va 2s .  c  o  m
 * See http://redis.io/commands/move
 * 
 * @param key key
 * @param dbIndex dbIndex
 * @return Boolean
 */
public Boolean move(byte[] key, int dbIndex) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.move(key, dbIndex);
        }
    });
}

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

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