|
47 | 47 | *
|
48 | 48 | * @author Christoph Strobl
|
49 | 49 | * @author Mark Paluch
|
| 50 | + * @author Marcin Grzejszczak |
50 | 51 | * @since 2.0
|
51 | 52 | */
|
52 | 53 | public interface ReactiveStringCommands {
|
@@ -193,6 +194,41 @@ default Mono<Boolean> set(ByteBuffer key, ByteBuffer value, Expiration expiratio
|
193 | 194 | */
|
194 | 195 | Flux<BooleanResponse<SetCommand>> set(Publisher<SetCommand> commands);
|
195 | 196 |
|
| 197 | + /** |
| 198 | + * Set {@literal value} for {@literal key} with {@literal expiration} and {@literal options}. Return the old |
| 199 | + * string stored at key, or nil if key did not exist. An error is returned and SET aborted if the value |
| 200 | + * stored at key is not a string. |
| 201 | + * |
| 202 | + * @param key must not be {@literal null}. |
| 203 | + * @param value must not be {@literal null}. |
| 204 | + * @param expiration must not be {@literal null}. Use {@link Expiration#persistent()} for no expiration time or |
| 205 | + * {@link Expiration#keepTtl()} to keep the existing. |
| 206 | + * @param option must not be {@literal null}. |
| 207 | + * @return |
| 208 | + * @see <a href="https://redis.io/commands/set">Redis Documentation: SET</a> |
| 209 | + * @since 3.4 |
| 210 | + */ |
| 211 | + @Nullable |
| 212 | + default Mono<ByteBuffer> setGet(ByteBuffer key, ByteBuffer value, Expiration expiration, SetOption option) { |
| 213 | + |
| 214 | + Assert.notNull(key, "Key must not be null"); |
| 215 | + Assert.notNull(value, "Value must not be null"); |
| 216 | + |
| 217 | + return setGet(Mono.just(SetCommand.set(key).value(value).withSetOption(option).expiring(expiration))).next() |
| 218 | + .map(CommandResponse::getOutput); |
| 219 | + } |
| 220 | + |
| 221 | + /** |
| 222 | + * Set each and every item separately by invoking {@link SetCommand}. Return the old |
| 223 | + * string stored at key, or nil if key did not exist. An error is returned and SET aborted if the value |
| 224 | + * stored at key is not a string. |
| 225 | + * |
| 226 | + * @param commands must not be {@literal null}. |
| 227 | + * @return {@link Flux} of {@link ByteBufferResponse} holding the {@link SetCommand} along with the command result. |
| 228 | + * @see <a href="https://redis.io/commands/set">Redis Documentation: SET</a> |
| 229 | + */ |
| 230 | + Flux<ByteBufferResponse<SetCommand>> setGet(Publisher<SetCommand> commands); |
| 231 | + |
196 | 232 | /**
|
197 | 233 | * Get single element stored at {@literal key}.
|
198 | 234 | *
|
|
0 commit comments