Redis strings vs Redis hashes to represent JSON: efficiency?

I want to store a JSON payload into redis. There’s really 2 ways I can do this:

  1. One using a simple string keys and values.
    key:user, value:payload (the entire JSON blob which can be 100-200 KB)

    SET user:1 payload

  2. Using hashes

    HSET user:1 username "someone"
    HSET user:1 location "NY"
    HSET user:1 bio "STRING WITH OVER 100 lines"

Keep in mind that if I use a hash, the value length isn’t predictable. They’re not all short such as the bio example above.

Which is more memory efficient? Using string keys and values, or using a hash?

4 Answers
4

Leave a Comment