Redis strings vs Redis hashes to represent JSON: efficiency? -


i want store json payload redis. there's 2 ways can this:

  1. one using simple string keys , values.
    key:user, value:payload (the entire json blob can 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 on 100 lines"

keep in mind if use hash, value length isn't predictable. they're not short such bio example above.

which more memory efficient? using string keys , values, or using hash?

it depends on how access data:

go option 1:

  • if use of fields on of accesses.
  • if there variance on possible keys

go option 2:

  • if use single fields on of accesses.
  • if know fields available

p.s.: rule of thumb, go option requires fewer queries on of use cases.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -