I am a newbie to Redis. I want to store and search over a list of custom objects in Redis cache. custom object has 4 attribute
- configKey
- configScope
- valueType
- configValue
Sample custom object
{"configScope":"country","configValue":"india","configKey":"country","valueType":"string"}
{"configScope":"integer","configValue":"3","configKey":"integer","valueType":"string"}
{"configScope":"sport","configValue":"sport","configKey":"sport","valueType":"string"}
{"configScope":"country","configValue":"india","configKey":"country","valueType":"string"}
couldn't understand how to store these object as i can efficiently search the string based configKey or configScope or configValue.
have written sample code but it is only giving result based on exact key
for (CustomObject model : list) {
CustomObject ec = (CustomObject) model;
syncCommands.lpush("orgId:EC:"+count++, ec.toString());
}
KeyScanCursor<String> cursor = syncCommands.scan(ScanArgs.Builder.limit(50).match("orgId:EC:10"));
while (!cursor.isFinished()) {
for (String key : cursor.getKeys()) {
List<String> value = syncCommands.lrange(key, 0, 50);
System.out.println(key + " - " + value);
}
cursor = syncCommands.scan(cursor,
ScanArgs.Builder.limit(50).match("orgId:EC:10"));
}
Any idea or reference will be helpful.