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

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

Introduction

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

Prototype

@Nullable
Long rPushX(byte[] key, byte[] value);

Source Link

Document

Append values to key only if the list exists.

Usage

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

public Long rightPushIfPresent(K key, V value) {
    final byte[] rawKey = rawKey(key);
    final byte[] rawValue = rawValue(value);
    return execute(new RedisCallback<Long>() {

        public Long doInRedis(RedisConnection connection) {
            connection.select(dbIndex);/* w ww .  ja v a2  s.  co m*/
            return connection.rPushX(rawKey, rawValue);
        }
    }, true);
}

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

/**
 * Append {@code} values to {@code key} only if the list exists.
 * <p>//from www .ja  v  a 2 s .  co  m
 * See http://redis.io/commands/rpushx
 * 
 * @param key key
 * @param value value
 * @return Long
 */
public static Long rPushX(byte[] key, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.rPushX(key, value);
        }
    });
}

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

/**
 * Append {@code} values to {@code key} only if the list exists.
 * <p>//w  w w  .j  a v  a  2  s.  c  om
 * See http://redis.io/commands/rpushx
 * 
 * @param key key
 * @param value value
 * @return Long
 */
public Long rPushX(byte[] key, byte[] value) {
    return redisTemplate.execute(new RedisCallback<Long>() {
        @Override
        public Long doInRedis(RedisConnection redis) throws DataAccessException {
            return redis.rPushX(key, value);
        }
    });
}