Skip to content

ReactiveRedisConnection ZAddCommand nx and xx does not work as expected #2731

Closed
@yeunghl-shoalter

Description

@yeunghl-shoalter
this.reactiveRedisTemplate.getConnectionFactory()
            .getReactiveConnection()
            .zSetCommands()
            .zAdd(Mono.just(
                  ReactiveZSetCommands.ZAddCommand
                        .tuple(new DefaultTuple(
                              ByteUtils.getBytes(ByteBuffer.wrap(storeSkuId.getBytes())),
                              (double)(LocalDateTime.now().toEpochSecond(ZoneOffset.UTC))))
                        .to(ByteBuffer.wrap(storeId.getBytes()))
                        .xx()));
                        

In the Redis official document, it claims that XX only update elements that already exist. Don't add new elements. However, the above code will still insert a non-exist element.

Also, why it will use flag called upsert to represent whether it is nx or xx? The meaning of upsert does not match with the actual usage of them.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions