Joe
Joe

Reputation: 13101

Redis - How to load multiple rows with the same key into Redis?

What is the best approach to load CSV with example:

id1,mike,123 id1,joe,234 id2,ben,235 id2,jack,445

The need is to query based on a first column (key) but there are keys that are repeating...

Upvotes: 0

Views: 725

Answers (1)

jjacobi
jjacobi

Reputation: 405

I recommend you to use HASHES because you're trying to do an object representation. According to best practices, you should use it every time it is possible; the key would be your first column and the value would be the repeating lines.

If you want more information about Redis data types, you can go on: https://redis.io/topics/data-types

Also this link is very useful for optimizing Redis: https://redis.io/topics/memory-optimization

From the memory optimization page:

Use hashes when possible

Small hashes are encoded in a very small space, so you should try representing your data using hashes every time it is possible

Upvotes: 1

Related Questions