Inserting a List into another List in Redis

2019-02-17 00:16发布

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 a to have a list where each component is also a list.

标签: redis
3条回答
Viruses.
2楼-- · 2019-02-17 00:37

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

查看更多
The star\"
3楼-- · 2019-02-17 00:57

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.

查看更多
太酷不给撩
4楼-- · 2019-02-17 00:58

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.

查看更多
登录 后发表回答