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

using jedis hmset method for inserting multiple field element in redis

$
0
0

I am implementing a simple redis command using jedis in java. The redis-cli command is:

hmset myhash key "value1" field2 "value2" field3 "value3"

The problem is that jedis's hmset method requires two parameters:

  • String key
  • Map <String, String> hash

Possible solution:

String key;
String value2;
String value3;
while(!toVisit.isEmpty()) {
    key = someQueue.poll()
    value2 = getTitle(key)
    value3 = getSize(value2)
    jedis.hmset(key, value2Map)
    jedis.hmset(key, value3Map)
...

But it feels a bit counter-intuitive having to implement three Tree Map objects to get their last added object in order to add a tuple with three fields in the redis db.

Just hoping for some better ideas before going ahead and implementing this.


Viewing all articles
Browse latest Browse all 2204

Trending Articles



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