Example usage for org.springframework.data.redis.support.collections RedisZSet getKey

List of usage examples for org.springframework.data.redis.support.collections RedisZSet getKey

Introduction

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

Prototype

K getKey();

Source Link

Document

Returns the key associated with this entity.

Usage

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

@SuppressWarnings("unchecked")
private void handleZset(RedisZSet<Object> zset, final Message<?> message) throws Exception {
    final Object payload = message.getPayload();

    if (this.extractPayloadElements) {
        final BoundZSetOperations<String, Object> ops = (BoundZSetOperations<String, Object>) this.redisTemplate
                .boundZSetOps(zset.getKey());

        if ((payload instanceof Map<?, ?> && this.isMapValuesOfTypeNumber((Map<?, ?>) payload))) {
            final Map<Object, Number> pyloadAsMap = (Map<Object, Number>) payload;
            this.processInPipeline(new PipelineCallback() {
                public void process() {
                    for (Object key : pyloadAsMap.keySet()) {
                        Number d = pyloadAsMap.get(key);
                        ops.add(key, d == null ? determineScore(message)
                                : NumberUtils.convertNumberToTargetClass(d, Double.class));
                    }//www. ja va  2s.  co  m
                }
            });
        } else if (payload instanceof Collection<?>) {
            this.processInPipeline(new PipelineCallback() {
                public void process() {
                    for (Object object : ((Collection<?>) payload)) {
                        ops.add(object, determineScore(message));
                    }
                }
            });
        } else {
            this.addToZset(zset, payload, this.determineScore(message));
        }
    } else {
        this.addToZset(zset, payload, this.determineScore(message));
    }
}

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

@SuppressWarnings("unchecked")
private void writeToZset(RedisZSet<Object> zset, final Message<?> message) throws Exception {
    final Object payload = message.getPayload();
    final BoundZSetOperations<String, Object> ops = (BoundZSetOperations<String, Object>) this.redisTemplate
            .boundZSetOps(zset.getKey());
    final boolean zsetIncrementHeader = this.extractZsetIncrementHeader(message);
    if (this.extractPayloadElements) {
        if ((payload instanceof Map<?, ?> && this.verifyAllMapValuesOfTypeNumber((Map<?, ?>) payload))) {
            final Map<Object, Number> payloadAsMap = (Map<Object, Number>) payload;
            this.processInPipeline(new PipelineCallback() {
                public void process() {
                    for (Entry<Object, Number> entry : payloadAsMap.entrySet()) {
                        Number d = entry.getValue();
                        incrementOrOverwrite(ops, entry.getKey(),
                                d == null ? determineScore(message)
                                        : NumberUtils.convertNumberToTargetClass(d, Double.class),
                                zsetIncrementHeader);
                    }//from   w  ww  .ja  v  a  2  s.c om
                }
            });
        } else if (payload instanceof Collection<?>) {
            this.processInPipeline(new PipelineCallback() {
                public void process() {
                    for (Object object : ((Collection<?>) payload)) {
                        incrementOrOverwrite(ops, object, determineScore(message), zsetIncrementHeader);
                    }
                }
            });
        } else {
            this.incrementOrOverwrite(ops, payload, this.determineScore(message), zsetIncrementHeader);
        }
    } else {
        this.incrementOrOverwrite(ops, payload, this.determineScore(message), zsetIncrementHeader);
    }
}