2
go-redis/cache 库分析与使用
source link: https://pandaychen.github.io/2023/03/25/A-GOREDIS-CACHE-ANALYSIS/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
0x00 前言
go-redis/cache是一个小而精悍的项目,实现了本地缓存配合redis(远端缓存)的高性能cache,可借鉴的地方两点(以V8
版本分析):
- 缓存的操作语义(本地/远程)
- singleflight机制的应用
0x01 结构
Options
type Options struct {
Redis rediser
LocalCache LocalCache
StatsEnabled bool
Marshal MarshalFunc //(反)序列化方法
Unmarshal UnmarshalFunc
}
可以传入本地缓存实现LocalCache
以及远程缓存实现rediser
,项目提供了默认的LocalCache
实现
0x02 参考
Related Issues not found
Please contact @pandaychen to initialize the comment
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK