2

go-redis/cache 库分析与使用

 1 year ago
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.
neoserver,ios ssh client

0x00 前言

go-redis/cache是一个小而精悍的项目,实现了本地缓存配合redis(远端缓存)的高性能cache,可借鉴的地方两点(以V8版本分析):

  1. 缓存的操作语义(本地/远程)
  2. singleflight机制的应用

0x01 结构

Options

type Options struct {
	Redis        rediser
	LocalCache   LocalCache
	StatsEnabled bool
	Marshal      MarshalFunc    //(反)序列化方法
	Unmarshal    UnmarshalFunc
}

可以传入本地缓存实现LocalCache以及远程缓存实现rediser,项目提供了默认的LocalCache实现

0x02 参考

go-redis/cache


Related Issues not found

Please contact @pandaychen to initialize the comment


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK