Sorting 排序redis缓存
如何对我的redis缓存进行排序 数据:Sorting 排序redis缓存,sorting,caching,redis,Sorting,Caching,Redis,如何对我的redis缓存进行排序 数据: SADD key '{"id":250,"store_id":3,"url_path":"\/blog\/testblog123123", "status":"Published","title":"TestBlog123123", '"description":"","image":null,"description_2":"", "date":"2017-04-17","blogcategory":"Category 3"}' 接下来,我需要按id
SADD key '{"id":250,"store_id":3,"url_path":"\/blog\/testblog123123",
"status":"Published","title":"TestBlog123123",
'"description":"","image":null,"description_2":"",
"date":"2017-04-17","blogcategory":"Category 3"}'
接下来,我需要按id对密钥进行排序
这项工作:
SORT key BY *->id DESC
。。。但只有当:
id > 10
因为redis只排序第一个数字
也许我应该使用另一个命令来添加,但我需要JSON格式。您可以从头开始使用排序集吗
ZADD key 250 '{"id":250,"store_id":3,"url_path":"\/blog\/testblog123123",
"status":"Published","title":"TestBlog123123",
'"description":"","image":null,"description_2":"",
"date":"2017-04-17","blogcategory":"Category 3"}'
我也不知道为什么在这里使用Set,因为Set元素的唯一性只能保证整个JSON字符串。如果您的JSON序列化程序更改JSON dict中两个字段的顺序,它将生成另一个唯一的字符串,您将得到一个悬空的旧字符串。如果向字符串中添加更多字段,同样适用