Skip to content

Commit 4f5e124

Browse files
author
codeba
committed
feat: Add setObjectEx, setObjectEXAsync methods
1 parent eac79e8 commit 4f5e124

File tree

2 files changed

+82
-62
lines changed

2 files changed

+82
-62
lines changed

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KString.java

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import java.util.Optional;
2222
import java.util.concurrent.CompletableFuture;
2323

24+
/**
25+
* The interface K string.
26+
*/
2427
public interface KString extends KStringAsync {
2528
/**
2629
* Append.
@@ -113,34 +116,6 @@ public interface KString extends KStringAsync {
113116
*/
114117
double incrByFloat(String key, double increment);
115118

116-
/**
117-
* Compare and set boolean.
118-
*
119-
* @param key the key
120-
* @param expect the expect
121-
* @param update the update
122-
* @return the boolean
123-
*/
124-
boolean compareAndSet(String key, long expect, long update);
125-
126-
/**
127-
* Compare and set boolean.
128-
*
129-
* @param key the key
130-
* @param expect the expect
131-
* @param update the update
132-
* @return the boolean
133-
*/
134-
boolean compareAndSet(String key, double expect, double update);
135-
136-
/**
137-
* Set.
138-
*
139-
* @param key the key
140-
* @param value the value
141-
*/
142-
void setObject(String key, Object value);
143-
144119
/**
145120
* M get async completable future.
146121
*
@@ -198,6 +173,15 @@ public interface KString extends KStringAsync {
198173
*/
199174
void set(String key, String value);
200175

176+
/**
177+
* Sets ex.
178+
*
179+
* @param key the key
180+
* @param value the value
181+
* @param duration the duration
182+
*/
183+
void setEX(String key, String value, Duration duration);
184+
201185
/**
202186
* Set.
203187
*
@@ -214,6 +198,23 @@ public interface KString extends KStringAsync {
214198
*/
215199
void set(String key, Double value);
216200

201+
/**
202+
* Set.
203+
*
204+
* @param key the key
205+
* @param value the value
206+
*/
207+
void setObject(String key, Object value);
208+
209+
/**
210+
* Sets object ex.
211+
*
212+
* @param key the key
213+
* @param value the value
214+
* @param duration the duration
215+
*/
216+
void setObjectEx(String key, Object value, Duration duration);
217+
217218
/**
218219
* Compare and set boolean.
219220
*
@@ -225,13 +226,24 @@ public interface KString extends KStringAsync {
225226
boolean compareAndSet(String key, String expect, String update);
226227

227228
/**
228-
* Sets ex.
229+
* Compare and set boolean.
229230
*
230-
* @param key the key
231-
* @param value the value
232-
* @param duration the duration
231+
* @param key the key
232+
* @param expect the expect
233+
* @param update the update
234+
* @return the boolean
233235
*/
234-
void setEX(String key, String value, Duration duration);
236+
boolean compareAndSet(String key, long expect, long update);
237+
238+
/**
239+
* Compare and set boolean.
240+
*
241+
* @param key the key
242+
* @param expect the expect
243+
* @param update the update
244+
* @return the boolean
245+
*/
246+
boolean compareAndSet(String key, double expect, double update);
235247

236248
/**
237249
* Str len long.

redis-keeper-core/src/main/java/org/codeba/redis/keeper/core/KStringAsync.java

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import java.time.Duration;
2020
import java.util.concurrent.CompletableFuture;
2121

22+
/**
23+
* The interface K string async.
24+
*/
2225
public interface KStringAsync {
2326

2427
/**
@@ -112,28 +115,24 @@ public interface KStringAsync {
112115
*/
113116
CompletableFuture<Double> incrByFloatAsync(String key, double increment);
114117

115-
116118
/**
117-
* Compare and set async completable future.
119+
* Sets async.
118120
*
119-
* @param key the key
120-
* @param expect the expect
121-
* @param update the update
122-
* @return the completable future
121+
* @param key the key
122+
* @param value the value
123+
* @return the async
123124
*/
124-
CompletableFuture<Boolean> compareAndSetAsync(String key, long expect, long update);
125-
125+
CompletableFuture<Void> setObjectAsync(String key, Object value);
126126

127127
/**
128-
* Compare and set async completable future.
128+
* Sets object async.
129129
*
130-
* @param key the key
131-
* @param expect the expect
132-
* @param update the update
133-
* @return the completable future
130+
* @param key the key
131+
* @param value the value
132+
* @param duration the duration
133+
* @return the object async
134134
*/
135-
CompletableFuture<Boolean> compareAndSetAsync(String key, double expect, double update);
136-
135+
CompletableFuture<Void> setObjectEXAsync(String key, Object value, Duration duration);
137136

138137
/**
139138
* Sets async.
@@ -142,17 +141,17 @@ public interface KStringAsync {
142141
* @param value the value
143142
* @return the async
144143
*/
145-
CompletableFuture<Void> setObjectAsync(String key, Object value);
144+
CompletableFuture<Void> setAsync(String key, String value);
146145

147146
/**
148-
* Sets async.
147+
* Sets ex async.
149148
*
150-
* @param key the key
151-
* @param value the value
152-
* @return the async
149+
* @param key the key
150+
* @param value the value
151+
* @param duration the duration
152+
* @return the ex async
153153
*/
154-
CompletableFuture<Void> setAsync(String key, String value);
155-
154+
CompletableFuture<Void> setEXAsync(String key, String value, Duration duration);
156155

157156
/**
158157
* Sets async.
@@ -184,17 +183,26 @@ public interface KStringAsync {
184183
*/
185184
CompletableFuture<Boolean> compareAndSetAsync(String key, String expect, String update);
186185

187-
188186
/**
189-
* Sets ex async.
187+
* Compare and set async completable future.
190188
*
191-
* @param key the key
192-
* @param value the value
193-
* @param duration the duration
194-
* @return the ex async
189+
* @param key the key
190+
* @param expect the expect
191+
* @param update the update
192+
* @return the completable future
195193
*/
196-
CompletableFuture<Void> setEXAsync(String key, String value, Duration duration);
194+
CompletableFuture<Boolean> compareAndSetAsync(String key, long expect, long update);
195+
197196

197+
/**
198+
* Compare and set async completable future.
199+
*
200+
* @param key the key
201+
* @param expect the expect
202+
* @param update the update
203+
* @return the completable future
204+
*/
205+
CompletableFuture<Boolean> compareAndSetAsync(String key, double expect, double update);
198206

199207
/**
200208
* Str len async completable future.

0 commit comments

Comments
 (0)