redis performance, store json object as a string

前端 未结 4 404
夕颜
夕颜 2021-01-31 04:13

I need to save a User model, something like:

{ \"nickname\": \"alan\",
  \"email\": ...,
  \"password\":...,
  ...} // and a couple of other fields
4条回答
  •  滥情空心
    2021-01-31 05:09

    Truthfully, either way works fine. The way you store it is a design decision you will need to make. It depends on how you want to retrieve the user information, etc.

    In terms of performance, storing the JSON encoded version of the user object will use less memory and take less time for storage/retrieval. That is, JSON parsing is probably faster than retrieving each field from Redis. And, even if not, it is probably more memory efficient. The difference in performance is probably minimal anyway.

提交回复
热议问题