Question

I have to store more than 100 millions of key-values in my HashMultiMap (key can have multiple values). Now, I want to use Jedis for that. I download it from here - Jedis 2.0.0.0.jar as recomended to me here. Now, after little bit searching, I could not find any nice document that helps me as a beginner:

1) How to use Jedis (specifically, do I have to treat it as normal .jar files in java ex. like Guava) ?

2) How to implement HashMultiMap (key can have multiple values) in Redis ?

3) How to perform all insertion, searching etc. in Redis.

4) I found by searching Redis, many options like Jedis, Redis, Jredis etc. What are those variations ? And which one would me nice to me for solving this ?

Any information and/or link to any document will be helpful for me. Sorry, if any stupid questions I ask, because I have no idea about Redis. So, beginning idea will be valuable for me. Thanks.

Était-ce utile?

La solution

I'm afraid there isn't a simple way to achieve what you want. Redis only has normal hashes. One key - one value.

However, you can serialize your multiple values to a string and store that as a value. Of course, you lose ability to individually insert/update/remove items, you'll have to reset the whole value every time. But this might not be a problem for you.

Autres conseils

Redis has few internal types like lists or sets or associated hashes. I guess you can use sets for your case. It's better that serializing whle data because operations with internal types are atomic, and you will not need to worry about possible race conditions.

  1. check out https://github.com/xetorthio/jedis/wiki and http://redis.io/commands
  2. there are several ways which imply using list/sortedSet/hashs as a single fields of your multimap. Then a) make of subdatabases to provide separated namespaces i.e. limit what is your overall multimap ( select . and/or b) use the rich semantics the keys have in redis ( see example here ). You could make up your multimap simply using regular key/value mappings set/get with the key name additionally describing your map fields. You have a variety of options to get what you want. One of the last resorts is scripting.
  3. Depends!
  4. afaik, jedis is the most mature.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top