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

/**
 * Removes and returns last element from lists stored at {@code keys} (see: {@link #rPop(byte[])}). <br>
 * <b>Blocks connection</b> until element available or {@code timeout} reached.
 * <p>/*  www  .j  a  va 2  s . c om*/
 * See http://redis.io/commands/brpop
 * 
 * @param timeout timeout
 * @param keys keys
 * @return List<byte[]>
 */
public List<byte[]> bRPop(int timeout, byte[]... keys) {
    return redisTemplate.execute(new RedisCallback<List<byte[]>>() {
        @Override
        public List<byte[]> doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bRPop(timeout, keys);
        }
    });
}

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

/**
 * Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value.
 * <p>//from   w w  w  .j a  va2s.co m
 * See http://redis.io/commands/rpoplpush
 * 
 * @param srcKey srcKey
 * @param dstKey dstKey
 * @return byte[]
 */
public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.rPopLPush(srcKey, dstKey);
        }
    });
}

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

/**
 * Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value (see
 * {@link #rPopLPush(byte[], byte[])}). <br>
 * <b>Blocks connection</b> until element available or {@code timeout} reached.
 * <p>//from  ww w  . j ava 2 s  .  c o m
 * See http://redis.io/commands/brpoplpush
 * 
 * @param timeout timeout
 * @param srcKey srcKey
 * @param dstKey dstKey
 * @return byte[]
 */
public static byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bRPopLPush(timeout, srcKey, dstKey);
        }
    });
}

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

/**
 * Add given {@code values} to set at {@code key}.
 * <p>/*from   w  w w  . j ava 2s.c o m*/
 * See http://redis.io/commands/sadd
 * 
 * @param key key
 * @param values values
 * @return Long
 */
public static Long sAdd(byte[] key, byte[]... values) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sAdd(key, values);
        }
    });
}

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

/**
 * Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value (see
 * {@link #rPopLPush(byte[], byte[])}). <br>
 * <b>Blocks connection</b> until element available or {@code timeout} reached.
 * <p>// ww  w .  ja  v a 2 s  .c o  m
 * See http://redis.io/commands/brpoplpush
 * 
 * @param timeout timeout
 * @param srcKey srcKey
 * @param dstKey dstKey
 * @return byte[]
 */
public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.bRPopLPush(timeout, srcKey, dstKey);
        }
    });
}

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

/**
 * Remove given {@code values} from set at {@code key} and return the number of removed elements.
 * <p>/*from   w  ww  .j  ava  2s  .c om*/
 * See http://redis.io/commands/srem
 * 
 * @param key key
 * @param values values
 * @return Long
 */
public static Long sRem(byte[] key, byte[]... values) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sRem(key, values);
        }
    });
}

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

/**
 * Add given {@code values} to set at {@code key}.
 * <p>//  w  w  w  .  ja v  a 2  s .  c  om
 * See http://redis.io/commands/sadd
 * 
 * @param key key
 * @param values values
 * @return Long
 */
public Long sAdd(byte[] key, byte[]... values) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sAdd(key, values);
        }
    });
}

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

/**
 * Remove and return a random member from set at {@code key}.
 * <p>//from ww w  .  jav  a  2s .c o  m
 * See http://redis.io/commands/spop
 * 
 * @param key key
 * @return byte[]
 */
public static byte[] sPop(byte[] key) {
    return redisTemplate.execute(new RedisCallback<byte[]>() {
        @Override
        public byte[] doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sPop(key);
        }
    });
}

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

/**
 * Remove given {@code values} from set at {@code key} and return the number of removed elements.
 * <p>//from   w w w.  j av  a 2 s .c  om
 * See http://redis.io/commands/srem
 * 
 * @param key key
 * @param values values
 * @return Long
 */
public Long sRem(byte[] key, byte[]... values) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sRem(key, values);
        }
    });
}

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

/**
 * Move {@code value} from {@code srcKey} to {@code destKey}
 * <p>/*from  w ww. j a  v a  2 s. c  o  m*/
 * See http://redis.io/commands/smove
 * 
 * @param srcKey srcKey
 * @param destKey destKey
 * @param value value
 * @return Boolean
 */
public static Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Boolean>() {
        @Override
        public Boolean doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.sMove(srcKey, destKey, value);
        }
    });
}