Redis strings vs Redis hashes to represent JSON: efficiency?

前端 未结 3 2125
你的背包
你的背包 2020-12-02 03:43

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

3条回答
  •  孤街浪徒
    2020-12-02 04:00

    It depends on how you access the data:

    Go for Option 1:

    • If you use most of the fields on most of your accesses.
    • If there is variance on possible keys

    Go for Option 2:

    • If you use just single fields on most of your accesses.
    • If you always know which fields are available

    P.S.: As a rule of the thumb, go for the option which requires fewer queries on most of your use cases.

提交回复
热议问题