Redis strings vs Redis hashes to represent JSON: efficiency? -
i want store json payload redis. there's 2 ways can this:
one using simple string keys , values.
key:user, value:payload (the entire json blob can 100-200 kb)set user:1 payload
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
Post a Comment