patch getKeysAll
This commit is contained in:
parent
c7dde27a82
commit
e147e995bb
1 changed files with 1 additions and 14 deletions
|
@ -2,13 +2,10 @@ package me.unurled.sacredrealms.sr.data;
|
||||||
|
|
||||||
import static me.unurled.sacredrealms.sr.utils.Logger.error;
|
import static me.unurled.sacredrealms.sr.utils.Logger.error;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.unurled.sacredrealms.sr.SR;
|
import me.unurled.sacredrealms.sr.SR;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import redis.clients.jedis.JedisPooled;
|
import redis.clients.jedis.JedisPooled;
|
||||||
import redis.clients.jedis.params.ScanParams;
|
|
||||||
import redis.clients.jedis.resps.ScanResult;
|
|
||||||
|
|
||||||
public class Redis implements DataHandler {
|
public class Redis implements DataHandler {
|
||||||
|
|
||||||
|
@ -82,16 +79,6 @@ public class Redis implements DataHandler {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getKeysAll(@NotNull String key) {
|
public List<String> getKeysAll(@NotNull String key) {
|
||||||
String cursor = "0";
|
return client.keys(key + "*").stream().toList();
|
||||||
ScanParams params = new ScanParams().match(key);
|
|
||||||
List<String> keys = new ArrayList<>();
|
|
||||||
|
|
||||||
do {
|
|
||||||
ScanResult<String> result = client.scan(cursor, params);
|
|
||||||
cursor = result.getCursor();
|
|
||||||
keys.addAll(result.getResult());
|
|
||||||
} while (!cursor.equals("0"));
|
|
||||||
|
|
||||||
return keys;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue