将一个列表插入到Redis中的另一个列表中 [英] Inserting a List into another List in Redis
问题描述
这是否可能在另一个数据结构中包含一个数据结构?到目前为止,我只能在列表中插入字符串或数字.
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 列表成员只能是字符串.
Simple answer: No, Redis list members can only be strings.
复杂的答案:你可以用字符串做很多事情.您可以使用多种不同的格式(JSON、XML、CSV、特定于语言的序列化等)将列表序列化为字符串.Redis 可以保存非常大的字符串值,因此您可以仅存储指向包含实际值的键的标识符,或者您可以拥有值本身的序列化列表.
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.
这篇关于将一个列表插入到Redis中的另一个列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!