File tree Expand file tree Collapse file tree 2 files changed +22
-16
lines changed
src/main/java/org/springframework/data/redis Expand file tree Collapse file tree 2 files changed +22
-16
lines changed Original file line number Diff line number Diff line change 16
16
package org .springframework .data .redis .cache ;
17
17
18
18
import java .util .ArrayList ;
19
- import java .util .Collections ;
20
19
import java .util .Iterator ;
21
20
import java .util .List ;
22
21
import java .util .NoSuchElementException ;
23
- import java .util .Optional ;
22
+ import java .util .Set ;
24
23
25
24
import org .springframework .data .redis .connection .RedisConnection ;
26
25
import org .springframework .data .redis .core .Cursor ;
33
32
* @author Mark Paluch
34
33
* @author Christoph Strobl
35
34
* @author John Blum
35
+ * @author Yong-Hyun Kim
36
36
* @since 2.6
37
37
*/
38
38
public abstract class BatchStrategies {
@@ -79,14 +79,17 @@ static class Keys implements BatchStrategy {
79
79
@ Override
80
80
public long cleanCache (RedisConnection connection , String name , byte [] pattern ) {
81
81
82
- byte [][] keys = Optional .ofNullable (connection .keys (pattern )).orElse (Collections .emptySet ())
83
- .toArray (new byte [0 ][]);
82
+ RedisKeyCommands commands = connection .keyCommands ();
84
83
85
- if (keys .length > 0 ) {
86
- connection .del (keys );
87
- }
84
+ Set <byte []> keys = commands .keys (pattern );
85
+
86
+ if (keys == null || keys .isEmpty ()) {
87
+ return 0 ;
88
+ }
89
+
90
+ commands .del (keys .toArray (new byte [0 ][]));
88
91
89
- return keys .length ;
92
+ return keys .size () ;
90
93
}
91
94
}
92
95
Original file line number Diff line number Diff line change 34
34
*
35
35
* @author Mark Paluch
36
36
* @author Christoph Strobl
37
+ * @author Yong-Hyun Kim
37
38
* @since 2.0
38
39
*/
39
40
public class RedisPassword {
@@ -54,10 +55,11 @@ private RedisPassword(char[] thePassword) {
54
55
*/
55
56
public static RedisPassword of (@ Nullable String passwordAsString ) {
56
57
57
- return Optional .ofNullable (passwordAsString ) //
58
- .filter (StringUtils ::hasText ) //
59
- .map (it -> new RedisPassword (it .toCharArray ())) //
60
- .orElseGet (RedisPassword ::none );
58
+ if (!StringUtils .hasText (passwordAsString )) {
59
+ return none ();
60
+ }
61
+
62
+ return new RedisPassword (passwordAsString .toCharArray ());
61
63
}
62
64
63
65
/**
@@ -68,10 +70,11 @@ public static RedisPassword of(@Nullable String passwordAsString) {
68
70
*/
69
71
public static RedisPassword of (@ Nullable char [] passwordAsChars ) {
70
72
71
- return Optional .ofNullable (passwordAsChars ) //
72
- .filter (it -> !ObjectUtils .isEmpty (passwordAsChars )) //
73
- .map (it -> new RedisPassword (Arrays .copyOf (it , it .length ))) //
74
- .orElseGet (RedisPassword ::none );
73
+ if (ObjectUtils .isEmpty (passwordAsChars )) {
74
+ return none ();
75
+ }
76
+
77
+ return new RedisPassword (Arrays .copyOf (passwordAsChars , passwordAsChars .length ));
75
78
}
76
79
77
80
/**
You can’t perform that action at this time.
0 commit comments