spring-projects / spring-data-redis

Provides support to increase developer productivity in Java when using Redis, a key-value store. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-redis/
Apache License 2.0
1.77k stars 1.17k forks source link

Inconsistent Redis Scripting API #3010

Closed ghoshbishakh closed 1 month ago

ghoshbishakh commented 1 month ago

The following example does not work:

https://github.com/spring-projects/spring-data-redis/blob/main/src/main/antora/modules/ROOT/pages/redis/scripting.adoc?plain=1#L55

Correct code will be:

public class Example {

  @Autowired
  ReactiveRedisOperations<String, String> redisOperations;

  @Autowired
  RedisScript<Boolean> script;

  public Flux<Boolean> checkAndSet(String expectedValue, String newValue) {
    return redisOperations.execute(script, singletonList("key"), expectedValue, newValue);
  }
}
mp911de commented 1 month ago

Thanks for bringing this to our attention. We've updated documentation for 3.2 and 3.3 development lines. For 3.4, we introduced an overload accepting varargs in the reactive flow allowing a simpler invocation scheme.