如何訪問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如何用?
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章