I have 3 keys1111-2222-44441111-2222-33331112-2222-3333
Using a partial key 1111, i want to be able to return the values for the keys 1111-2222-4444, 1111-2222-3333.
As I understand it the method hscan should do this.
public List<String> getValues(String key) { List <String> values = null; Jedis jedis = jedisPool.getResource(); ScanParams scanParams = new ScanParams(); String cur = redis.clients.jedis.ScanParams.SCAN_POINTER_START; boolean cycleIsFinished = false; while(!cycleIsFinished) { ScanResult<Entry<String, String>> scanResult = jedis.hscan(key, cur, scanParams); List<Entry<String, String>> result = scanResult.getResult(); values = getValues(result); cur = scanResult.getCursor(); if (cur.equals("0")) { cycleIsFinished = true; } } return values; }
But jedis.hscan returns empty for result
ScanResult<Entry<String, String>> scanResult = jedis.hscan(key, cur, scanParams); List<Entry<String, String>> result = scanResult.getResult();
The code should work, is the problem with the key.This is the test I use to call the code
@Test void getData() { String value = service.getValue("1111-2222-4444"); System.out.println("VALUE "+value); List<String> values = service.getValues("1111"); }