Example usage for org.springframework.data.redis.support.collections RedisSet add

List of usage examples for org.springframework.data.redis.support.collections RedisSet add

Introduction

In this page you can find the example usage for org.springframework.data.redis.support.collections RedisSet add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:org.springframework.integration.redis.outbound.RedisCollectionPopulatingMessageHandler.java

@SuppressWarnings("unchecked")
private void handleSet(final RedisSet<Object> set, Message<?> message) {
    final Object payload = message.getPayload();
    if (this.extractPayloadElements && payload instanceof Collection<?>) {
        final BoundSetOperations<String, Object> ops = (BoundSetOperations<String, Object>) this.redisTemplate
                .boundSetOps(set.getKey());

        this.processInPipeline(new PipelineCallback() {
            public void process() {
                for (Object object : ((Collection<?>) payload)) {
                    ops.add(object);//from   w w  w .j a va 2 s. c om
                }
            }
        });
    } else {
        set.add(payload);
    }
}

From source file:org.springframework.integration.redis.outbound.RedisStoreWritingMessageHandler.java

@SuppressWarnings("unchecked")
private void writeToSet(final RedisSet<Object> set, Message<?> message) {
    final Object payload = message.getPayload();
    if (this.extractPayloadElements && payload instanceof Collection<?>) {
        final BoundSetOperations<String, Object> ops = (BoundSetOperations<String, Object>) this.redisTemplate
                .boundSetOps(set.getKey());

        this.processInPipeline(new PipelineCallback() {
            public void process() {
                for (Object object : ((Collection<?>) payload)) {
                    ops.add(object);//from  w  ww .j  a  v  a2s.  co m
                }
            }
        });
    } else {
        set.add(payload);
    }
}