Hello.
Using the code below to search for all keys, when I set the parameter COUNT = 100 it returns all keys correctly, if I put any value above 100, some key does not return.
//START CODE
static JedisSentinelPool pool =null;
static {
JedisPoolConfig conf = new JedisPoolConfig();
conf.setMaxTotal(2048);
conf.setMaxIdle(1024);
conf.setMinIdle(1);
conf.setMaxWaitMillis(1000);
Set<String> sentinels = getSentinels();
JedisSentinelPool pool = new JedisSentinelPool("mymaster", sentinels, conf, "pass");
}
public static Set<String> keys(String pattern) {
Jedis redis = null;
try {
redis = pool.getResource();
Set<String> keys = new HashSet<String>();
ScanParams params = new ScanParams();
params.count(100); // <<<====================
params.match(pattern);
ScanResult<String> scanResult = redis.scan("0", params);
while (!"0".equals(scanResult.getCursor())) {
keys.addAll(scanResult.getResult());
scanResult = redis.scan(scanResult.getCursor(), params);
}
return keys;
} finally {
if (redis != null) {
redis.close();
}
}
}
//END CODE
-------------------
INFO:
- Java 7;
- Jedis 3.2.0 (also tested with 2.10.2);
- Redis 4.0.6 (there is no way to update) (with 20000 keys)
---------------
Example:
public static void main(String[] args) throws Exception {
String key1 = "RF:P:450:*";
Set<String> entryInCache = keys(key1);
System.out.println("amount returned="+entryInCache.size());
}
//with count(100) print in log:
amount returned=8
//with count(500) print in log:
--------------
could someone explain to me why this happens?