Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Add custom object list to Redis

$
0
0

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

  1. configKey
  2. configScope
  3. valueType
  4. 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.


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>