首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
›
Redis
›
Redis 入门指南
›
phpRedisAdmin
›
Deploy Redis on Ubuntu or Debian
V2EX
›
Redis
redis 如何实现按 id 或者 timestamp 数据筛选?
whatisnew
·
2015-04-24 14:35:49 +08:00
· 4470 次点击
这是一个创建于 3340 天前的主题,其中的信息可能已经有所发展或是发生改变。
比如,像v2ex首页,给他增加:
一个按 timestamp 大于昨天的筛选,
一个 id(t/185874) 值大于 185874 的筛选。
redis 实现这样的数据筛选,如何设计?
TIMESTAMP
筛选
Redis
3 条回复
•
2015-04-27 11:01:32 +08:00
1
fuxkcsdn
2015-04-24 14:41:13 +08:00
1
使用 sorted sets
将 timestamp 或 id 作为 score
2
whatisnew
OP
2015-04-24 14:47:06 +08:00
@
fuxkcsdn
然后,标题和内容存到 list?
取出符合条件的 score 然后,再去取 list 吗?
3
fuxkcsdn
2015-04-27 11:01:32 +08:00
@
whatisnew
对, sorted sets 的 member 存放 ID,然后根据 ID 去取数据,redis里存放数据的 KEY 用类似 topic_content_123 这样,如果数据是存放在 MYSQL 里用 where ·id· in(...)
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
905 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 32ms ·
UTC 20:47
·
PVG 04:47
·
LAX 13:47
·
JFK 16:47
Developed with
CodeLauncher
♥ Do have faith in what you're doing.