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.RedisUtils.java

/**
 * Set the {@code value} and expiration in {@code milliseconds} for {@code key}.
 * <p>//w  w w.  ja  v a  2  s .  c o m
 * See http://redis.io/commands/psetex
 * 
 * @param key must not be {@literal null}.
 * @param milliseconds exprise milliseconds
 * @param value must not be {@literal null}.
 * @since 1.3
 */
public static void pSetEx(byte[] key, long milliseconds, byte[] value) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.pSetEx(key, milliseconds, value);
            return null;
        }
    });
}

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

/**
 * Set the {@code value} and expiration in {@code seconds} for {@code key}.
 * <p>/*w ww  .  jav a 2s .c o m*/
 * See http://redis.io/commands/setex
 * 
 * @param key must not be {@literal null}.
 * @param seconds exprise time
 * @param value must not be {@literal null}.
 */
public void setEx(byte[] key, long seconds, byte[] value) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.setEx(key, seconds, value);
            return null;
        }
    });
}

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

/**
 * Set multiple keys to multiple values using key-value pairs provided in {@code tuple}.
 * <p>// w  w w .  ja  v  a2  s  .  co  m
 * See http://redis.io/commands/mset
 * 
 * @param tuple tuple
 */
public static void mSet(Map<byte[], byte[]> tuple) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.mSet(tuple);
            return null;
        }
    });
}

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

/**
 * Set the {@code value} and expiration in {@code milliseconds} for {@code key}.
 * <p>/*www .  ja va  2s .  c o m*/
 * See http://redis.io/commands/psetex
 * 
 * @param key must not be {@literal null}.
 * @param milliseconds exprise milliseconds
 * @param value must not be {@literal null}.
 * @since 1.3
 */
public void pSetEx(byte[] key, long milliseconds, byte[] value) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.pSetEx(key, milliseconds, value);
            return null;
        }
    });
}

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

/**
 * Set multiple keys to multiple values using key-value pairs provided in {@code tuple} only if the provided key does
 * not exist.//from w  ww  . j a  v a2 s.  c o m
 * <p>
 * See http://redis.io/commands/msetnx
 * 
 * @param tuple tuple
 * @return Boolean
 */
public static Boolean mSetNX(Map<byte[], byte[]> tuple) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.mSetNX(tuple);
        }
    });
}

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

/**
 * Set multiple keys to multiple values using key-value pairs provided in {@code tuple}.
 * <p>/*from  w ww.j a va  2  s.c o  m*/
 * See http://redis.io/commands/mset
 * 
 * @param tuple tuple
 */
public void mSet(Map<byte[], byte[]> tuple) {
    redisTemplate.execute(new RedisCallback<Void>() {
        @Override
        public Void doInRedis(RedisConnection redis) throws DataAccessException {
            redis.mSet(tuple);
            return null;
        }
    });
}

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

/**
 * Increment value of {@code key} by 1.// ww w .j a v a 2  s.  c  o m
 * <p>
 * See http://redis.io/commands/incr
 * 
 * @param key must not be {@literal null}.
 * @return Long
 */
public static Long incr(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.incr(key);
        }
    });
}

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

/**
 * Set multiple keys to multiple values using key-value pairs provided in {@code tuple} only if the provided key does
 * not exist.//from w w w .ja  v a  2 s .  c  o  m
 * <p>
 * See http://redis.io/commands/msetnx
 * 
 * @param tuple tuple
 * @return Boolean
 */
public Boolean mSetNX(Map<byte[], byte[]> tuple) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.mSetNX(tuple);
        }
    });
}

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

/**
 * Increment value of {@code key} by {@code value}.
 * <p>//from  www . j  ava2  s. c o m
 * See http://redis.io/commands/incrby
 * 
 * @param key must not be {@literal null}.
 * @param value value
 * @return Long
 */
public static Long incrBy(byte[] key, long value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.incrBy(key, value);
        }
    });
}

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

/**
 * Increment value of {@code key} by 1.//from  www . ja v a  2s.  c  om
 * <p>
 * See http://redis.io/commands/incr
 * 
 * @param key must not be {@literal null}.
 * @return Long
 */
public Long incr(byte[] key) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.incr(key);
        }
    });
}