亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

redis 如何實(shí)現(xiàn)數(shù)據(jù)篩選
黃舟
黃舟 2017-04-22 09:00:37
0
6
1514

redis 如何實(shí)現(xiàn)數(shù)據(jù)按 id 或者 timestamp 篩選?
比如,像 sql 這樣

sqlselect * from news_table where id > '512';
select * from news_table where id > '512' and cat_id = '2';
select * from news_table where pubdate > 'yesterday';
sql-- news_table info
CREATE TABLE `news_table` (
    `id`                 int(10),
    `cat_id`,            int(10),
    `title`              text,
    `content`            longtext,
    `pubdate`            int(10),
);
黃舟
黃舟

人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!

reply all(6)
小葫蘆

Please take a look at redis's zset, scop can achieve your requirements, but the kind of query you mentioned with an id greater than 100% is best to change your mind in redis, this is not its strong point

伊謝爾倫

I think Key-Value database is not suitable for applications filtering by conditions.

If512這個(gè)條件是固定的,可以在添加文章的時(shí)候把大于512的元素加到一個(gè)集合里。
yesterday可以用EXPIRE comes true.

If the filtering conditions cannot be determined during design, it will be necessary to traverse the Hash table/linked list, which will not be very efficient...

大家講道理

What is 512? If it is a number with special meaning and often needs to be checked in this way, it is recommended that you store the set of id>512 in a separate map in redis, such as map_512, and just take out the entire map each time. If not, you can only take out the map every time and filter it locally. If this kind of query is very frequent and the filtering conditions are different, it is recommended to retrieve them all at once and then filter them uniformly.

Ty80

Thank you all for your replies! :)

If redis is not suitable for such needs, please recommend a suitable nosql such as mongodb?

左手右手慢動(dòng)作

If the data changes frequently, such as adding, modifying, and deleting keys, you can use mongodb, which is easy and enjoyable~

小葫蘆

Create another index or change to mongodb

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template