Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sorting 排序redis缓存_Sorting_Caching_Redis - Fatal编程技术网

Sorting 排序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

如何对我的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对密钥进行排序

这项工作:

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中两个字段的顺序,它将生成另一个唯一的字符串,您将得到一个悬空的旧字符串。如果向字符串中添加更多字段,同样适用