总领
好处:
- 简单高效的cache in-memory + single thread,主要就是快
O(100k)的写入+微妙级别的读 - 在pub/sub的设置中便宜
trade off: - not get the same garentee as DB for minimizing DB loss
- 在pub/sub中消息顺序不保证并且消息丢失也没有很好的机制
有哪些数据结构支持
Strings
Hashes (Objects)
Lists
Sets
Sorted Sets (Priority Queues)
Bloom Filters
Geospatial Indexes
Time Series
如何scale up
sharding by key
系统设计中我在什么时候会需要用到这个组件
- Cache - TTL 是多少
- Distributed lock when we acquire the lock we run INCR, if the response is 1 那就行,如果response > 1说明某个id被锁住了
- Redis可以用来做leaderboard,sorted list能很快得到最上面的值
- Redis rate limiting
- Reids GEOHASH