How to store array of objects in Redis?

后端 未结 3 1055
时光取名叫无心
时光取名叫无心 2021-01-13 06:44

I have an array of Objects that I want to store in Redis. I can break up the array part and store them as objects but I am not getting how I can get somethings like

<
3条回答
  •  -上瘾入骨i
    2021-01-13 07:16

    Redis is pretty simple key-value storage. Yes, there are other data structures like sets, but it has VERY limited query capabilities. For example, if you want to get find data by name, then you would have to to something like that:

    SET Name "serialized data of object"

    SET Name2 "serialized data of object2"

    SET Name3 "serialized data of object3"

    then:

    GET Name

    would return data.

    Of course this means that you can't store two entries with the same names.

    You can do limited text matching on keys using: http://redis.io/commands/scan

    To summarize: I think you should use other tool for complex queries.

提交回复
热议问题