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

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

Introduction

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

Prototype

@Nullable
byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey);

Source Link

Document

Remove the last element from list at srcKey , append it to dstKey and return its value.

Usage

From source file:com.mauersu.util.redis.DefaultListOperations.java

public V rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit) {
    final int tm = (int) TimeoutUtils.toSeconds(timeout, unit);
    final byte[] rawDestKey = rawKey(destinationKey);

    return execute(new ValueDeserializingRedisCallback(sourceKey) {

        protected byte[] inRedis(byte[] rawSourceKey, RedisConnection connection) {
            connection.select(dbIndex);/*from w  w  w  .ja va  2 s  . c o  m*/
            return connection.bRPopLPush(tm, rawSourceKey, rawDestKey);
        }
    }, true);
}

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 w ww  . j  av  a  2  s  .co  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.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>// w w  w.  j av 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);
        }
    });
}