@Override public Set<E> union(RedisSet<?> set) { return boundSetOps.union(set.getKey()); }
@SuppressWarnings("unchecked") private void writeToSet(final RedisSet<Object> set, Message<?> message) { final Object payload = message.getPayload(); if (this.extractPayloadElements && payload instanceof Collection<?>) { BoundSetOperations<String, Object> ops = (BoundSetOperations<String, Object>) this.redisTemplate.boundSetOps(set.getKey()); processInPipeline(() -> { for (Object object : ((Collection<?>) payload)) { ops.add(object); } }); } else { set.add(payload); } }
@Test @RedisAvailable public void testSetWithKeyAsHeader() { RedisSet<String> redisSet = new DefaultRedisSet<String>("pepboys", this.redisTemplate); assertEquals(0, redisSet.size()); Set<String> pepboys = new HashSet<String>(); pepboys.add("Manny"); pepboys.add("Moe"); pepboys.add("Jack"); Message<Set<String>> message = MessageBuilder.withPayload(pepboys).setHeader("redis_key", "pepboys").build(); this.setChannel.send(message); assertEquals(3, redisSet.size()); }
@SuppressWarnings("unchecked") private void writeToSet(final RedisSet<Object> set, Message<?> message) { final Object payload = message.getPayload(); if (this.extractPayloadElements && payload instanceof Collection<?>) { BoundSetOperations<String, Object> ops = (BoundSetOperations<String, Object>) this.redisTemplate.boundSetOps(set.getKey()); processInPipeline(() -> { for (Object object : ((Collection<?>) payload)) { ops.add(object); } }); } else { set.add(payload); } }
@Test @RedisAvailable public void testSetWithKeyAsHeaderNotParsed() { RedisSet<String> redisSet = new DefaultRedisSet<String>("pepboys", this.redisTemplate); assertEquals(0, redisSet.size()); Set<String> pepboys = new HashSet<String>(); pepboys.add("Manny"); pepboys.add("Moe"); pepboys.add("Jack"); Message<Set<String>> message = MessageBuilder.withPayload(pepboys).setHeader("redis_key", "pepboys").build(); this.setNotParsedChannel.send(message); assertEquals(1, redisSet.size()); }
@Override public Set<E> diff(RedisSet<?> set) { return boundSetOps.diff(set.getKey()); }
@Test @RedisAvailable public void testPojoIntoSet() { RedisSet<String> redisSet = new DefaultRedisSet<String>("pepboys", this.redisTemplate); assertEquals(0, redisSet.size()); String pepboy = "Manny"; Message<String> message = MessageBuilder.withPayload(pepboy).setHeader("redis_key", "pepboys").build(); this.pojoIntoSetChannel.send(message); assertEquals(1, redisSet.size()); }
@Override public Set<E> intersect(RedisSet<?> set) { return boundSetOps.intersect(set.getKey()); }
@Test @RedisAvailable public void testSetWithKeyAsHeaderSimple() { RedisSet<String> redisSet = new DefaultRedisSet<String>("foo", this.redisTemplate); assertEquals(0, redisSet.size()); Message<String> message = MessageBuilder.withPayload("foo") .setHeader(RedisHeaders.KEY, "foo").build(); this.setChannel.send(message); assertEquals(1, redisSet.size()); }
@Override public RedisSet<E> unionAndStore(RedisSet<?> set, String destKey) { boundSetOps.unionAndStore(set.getKey(), destKey); return new DefaultRedisSet<>(boundSetOps.getOperations().boundSetOps(destKey)); }
@Override public RedisSet<E> diffAndStore(RedisSet<?> set, String destKey) { boundSetOps.diffAndStore(set.getKey(), destKey); return new DefaultRedisSet<>(boundSetOps.getOperations().boundSetOps(destKey)); }
@Override public RedisSet<E> intersectAndStore(RedisSet<?> set, String destKey) { boundSetOps.intersectAndStore(set.getKey(), destKey); return new DefaultRedisSet<>(boundSetOps.getOperations().boundSetOps(destKey)); }
@Override public Set<E> intersect(RedisSet<?> set) { return boundSetOps.intersect(set.getKey()); }
@Override public Set<E> diff(RedisSet<?> set) { return boundSetOps.diff(set.getKey()); }
@Override public Set<E> union(RedisSet<?> set) { return boundSetOps.union(set.getKey()); }
@Override public Set<E> diff(RedisSet<?> set) { return boundSetOps.diff(set.getKey()); }
@Override public Set<E> union(RedisSet<?> set) { return boundSetOps.union(set.getKey()); }
@Override public Set<E> intersect(RedisSet<?> set) { return boundSetOps.intersect(set.getKey()); }
@Override public RedisSet<E> intersectAndStore(RedisSet<?> set, String destKey) { boundSetOps.intersectAndStore(set.getKey(), destKey); return new DefaultRedisSet<>(boundSetOps.getOperations().boundSetOps(destKey)); }
@Override public RedisSet<E> diffAndStore(RedisSet<?> set, String destKey) { boundSetOps.diffAndStore(set.getKey(), destKey); return new DefaultRedisSet<>(boundSetOps.getOperations().boundSetOps(destKey)); }