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 1616package org .springframework .data .redis .cache ;
1717
1818import java .util .ArrayList ;
19- import java .util .Collections ;
2019import java .util .Iterator ;
2120import java .util .List ;
2221import java .util .NoSuchElementException ;
23- import java .util .Optional ;
22+ import java .util .Set ;
2423
2524import org .springframework .data .redis .connection .RedisConnection ;
2625import org .springframework .data .redis .core .Cursor ;
3332 * @author Mark Paluch
3433 * @author Christoph Strobl
3534 * @author John Blum
35+ * @author Yong-Hyun Kim
3636 * @since 2.6
3737 */
3838public abstract class BatchStrategies {
@@ -79,14 +79,17 @@ static class Keys implements BatchStrategy {
7979 @ Override
8080 public long cleanCache (RedisConnection connection , String name , byte [] pattern ) {
8181
82- byte [][] keys = Optional .ofNullable (connection .keys (pattern )).orElse (Collections .emptySet ())
83- .toArray (new byte [0 ][]);
82+ RedisKeyCommands commands = connection .keyCommands ();
8483
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 ][]));
8891
89- return keys .length ;
92+ return keys .size () ;
9093 }
9194 }
9295
Original file line number Diff line number Diff line change 3434 *
3535 * @author Mark Paluch
3636 * @author Christoph Strobl
37+ * @author Yong-Hyun Kim
3738 * @since 2.0
3839 */
3940public class RedisPassword {
@@ -54,10 +55,11 @@ private RedisPassword(char[] thePassword) {
5455 */
5556 public static RedisPassword of (@ Nullable String passwordAsString ) {
5657
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 ());
6163 }
6264
6365 /**
@@ -68,10 +70,11 @@ public static RedisPassword of(@Nullable String passwordAsString) {
6870 */
6971 public static RedisPassword of (@ Nullable char [] passwordAsChars ) {
7072
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 ));
7578 }
7679
7780 /**
You can’t perform that action at this time.
0 commit comments