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

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

Introduction

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

Prototype

@Nullable
Long sAdd(byte[] key, byte[]... values);

Source Link

Document

Add given values to set at key .

Usage

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

public Long add(K key, V... values) {
    final byte[] rawKey = rawKey(key);
    final byte[][] rawValues = rawValues(values);
    return execute(new RedisCallback<Long>() {

        public Long doInRedis(RedisConnection connection) {
            connection.select(dbIndex);//from  ww w .j  av a  2 s  .  co  m
            return connection.sAdd(rawKey, rawValues);
        }
    }, true);
}

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

/**
 * Add given {@code values} to set at {@code key}.
 * <p>/* w  ww  .j a  v a  2s.c om*/
 * 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

/**
 * Add given {@code values} to set at {@code key}.
 * <p>/*from  w  w w.  ja v a 2s  .c  o m*/
 * 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);
        }
    });
}