我做了一个list来做id的索引,一个hash存储具体的数据
key | value |
---|---|
lists | app_id:12 |
lists | app_id:13 |
lists | app_id:14 |
key | field | value |
---|---|---|
app_id:12 | app_name | 天气预报 |
app_sort | 1 | |
app_id:13 | app_name | 游戏推荐 |
app_sort | 3 | |
app_id:14 | app_name | 新闻评论 |
app_sort | 2 |
我之前是lrange操作list获得相关的app_id,然后去hash使用getall获得具体的数据
现在加了个排序的功能,暂时没有相关思路,不知道怎么处理???
nosql is essentially different from relational databases,
Hash is the original data,
Your list is equivalent to a clustered index,
If you want to sort, you must traverse the data, then sort in memory, and then output. In fact, mysql does this too,
But why is mysql fast?
Because there is an index,
So just add the index,
Create a new key, type is zset or list,
zset is more convenient, the list must be refreshed regularly,
First get the id from zset or list, and then get the data from the hash.
Of course, you can also directly convert the data into json and store it in zset or list.