如何访问redis中的海量数据,又不影响其他请求访问?

1.如何高效访问redis的海量数据

分页

keys k[1 3]

有的就是不行,奇了怪了

先搁置

2.如何访问redis中的海量数据,又不影响其他请求访问?

redis是单线程

如果用keys * 来查,这边在窗口查呢,程序还在访问,还没执行完,绝对会影响其他请求访问redis,redis单线程,redis打满cpu,cpu飙升就会造成阻塞。

1.keys *  坚决不能用,在生产环境,运维要把keys * flushdb flushAll 禁用掉

2.scan 相当于mysql limit oracle rownum 

建议用scan 
 Warning: consider KEYS as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don’t use KEYS in your regular application code. If you’re looking for a way to find keys in a subset of your keyspace, consider using SCAN or sets.
scan如何用?
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章