Inserting a List into another List in Redis

后端 未结 3 412
灰色年华
灰色年华 2021-01-12 07:23

Is this possible to have a datastructure inside another data structure? So far I can only insert a string or a number into a list.

A desired data structure would be

相关标签:
3条回答
  • 2021-01-12 07:25

    Redis have a very limited set of data types which can be found here: Data types

    What you can do is to store the names of element lists in a list so it will effectively act as list of lists.

    0 讨论(0)
  • 2021-01-12 07:27

    Yes, you can store a id lists in a list, each id is a pointer to other redis list. You can use a multi/exec Pipeline Multiple Commands architecture to do all CRUD operations

    0 讨论(0)
  • 2021-01-12 07:43

    Simple answer: No, Redis list members can only be strings.

    Complex answer: There is a lot you can do with strings. You can serialize a list into a string using a number of different formats (JSON, XML, CSV, language specific serialization, etc.). Redis can hold pretty large string values so you can store just identifiers which point to a key containing the real values, or you can have a serialized list of the values themselves.

    0 讨论(0)
提交回复
热议问题