@@ -98,6 +98,50 @@ void set() {
98
98
valueOperations .get (key ).as (StepVerifier ::create ).expectNext (value ).verifyComplete ();
99
99
}
100
100
101
+ @ ParameterizedRedisTest // GH-2084
102
+ void setWithKeepTtl () {
103
+
104
+ K key = keyFactory .instance ();
105
+ V value1 = valueFactory .instance ();
106
+ V value2 = valueFactory .instance ();
107
+
108
+ valueOperations .set (key , value1 , Duration .ofMillis (5500 )).as (StepVerifier ::create ) //
109
+ .expectNext (true ) //
110
+ .verifyComplete ();
111
+ valueOperations .set (key , value2 , true ).as (StepVerifier ::create ) //
112
+ .expectNext (true ) //
113
+ .verifyComplete ();
114
+
115
+ valueOperations .get (key ).as (StepVerifier ::create ) //
116
+ .expectNext (value2 ) //
117
+ .verifyComplete ();
118
+ redisTemplate .getExpire (key ).as (StepVerifier ::create ) //
119
+ .assertNext (actual -> assertThat (actual ).isBetween (Duration .ofMillis (1 ), Duration .ofSeconds (6 ))) //
120
+ .verifyComplete ();
121
+ }
122
+
123
+ @ ParameterizedRedisTest // GH-2084
124
+ void setWithoutKeepTtl () {
125
+
126
+ K key = keyFactory .instance ();
127
+ V value1 = valueFactory .instance ();
128
+ V value2 = valueFactory .instance ();
129
+
130
+ valueOperations .set (key , value1 , Duration .ofMillis (5500 )).as (StepVerifier ::create ) //
131
+ .expectNext (true ) //
132
+ .verifyComplete ();
133
+ valueOperations .set (key , value2 , false ).as (StepVerifier ::create ) //
134
+ .expectNext (true ) //
135
+ .verifyComplete ();
136
+
137
+ valueOperations .get (key ).as (StepVerifier ::create ) //
138
+ .expectNext (value2 ) //
139
+ .verifyComplete ();
140
+ redisTemplate .getExpire (key ).as (StepVerifier ::create ) //
141
+ .assertNext (actual -> assertThat (actual ).isZero ()) //
142
+ .verifyComplete ();
143
+ }
144
+
101
145
@ ParameterizedRedisTest // DATAREDIS-602
102
146
void setWithExpiry () {
103
147
@@ -186,6 +230,58 @@ void setIfPresentWithExpiry() {
186
230
}).verifyComplete ();
187
231
}
188
232
233
+ @ ParameterizedRedisTest // GH-2084
234
+ void setIfPresentWithKeepTtl () {
235
+
236
+ K key = keyFactory .instance ();
237
+ V value1 = valueFactory .instance ();
238
+ V value2 = valueFactory .instance ();
239
+
240
+ valueOperations .setIfPresent (key , value1 , true ).as (StepVerifier ::create ) //
241
+ .expectNext (false ) //
242
+ .verifyComplete ();
243
+ valueOperations .set (key , value1 , Duration .ofMillis (5500 )).as (StepVerifier ::create ) //
244
+ .expectNext (true ) //
245
+ .verifyComplete ();
246
+
247
+ valueOperations .setIfPresent (key , value2 , true ).as (StepVerifier ::create ) //
248
+ .expectNext (true ) //
249
+ .verifyComplete ();
250
+
251
+ valueOperations .get (key ).as (StepVerifier ::create ) //
252
+ .expectNext (value2 ) //
253
+ .verifyComplete ();
254
+ redisTemplate .getExpire (key ).as (StepVerifier ::create ) //
255
+ .assertNext (actual -> assertThat (actual ).isBetween (Duration .ofMillis (1 ), Duration .ofSeconds (6 ))) //
256
+ .verifyComplete ();
257
+ }
258
+
259
+ @ ParameterizedRedisTest // GH-2084
260
+ void setIfPresentWithoutKeepTtl () {
261
+
262
+ K key = keyFactory .instance ();
263
+ V value1 = valueFactory .instance ();
264
+ V value2 = valueFactory .instance ();
265
+
266
+ valueOperations .setIfPresent (key , value1 , false ).as (StepVerifier ::create ) //
267
+ .expectNext (false ) //
268
+ .verifyComplete ();
269
+ valueOperations .set (key , value1 , Duration .ofMillis (5500 )).as (StepVerifier ::create ) //
270
+ .expectNext (true ) //
271
+ .verifyComplete ();
272
+
273
+ valueOperations .setIfPresent (key , value2 , false ).as (StepVerifier ::create ) //
274
+ .expectNext (true ) //
275
+ .verifyComplete ();
276
+
277
+ valueOperations .get (key ).as (StepVerifier ::create ) //
278
+ .expectNext (value2 ) //
279
+ .verifyComplete ();
280
+ redisTemplate .getExpire (key ).as (StepVerifier ::create ) //
281
+ .assertNext (actual -> assertThat (actual ).isZero ()) //
282
+ .verifyComplete ();
283
+ }
284
+
189
285
@ ParameterizedRedisTest // DATAREDIS-602
190
286
void multiSet () {
191
287
0 commit comments