cache

package
v0.0.0-...-26e1b9e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 0 Imported by: 0

README

Cache模块

Cache模块主要用于缓存数据,有两种实现。

1.redis:封装了三方库并添加了链路追踪和指标监控的功能。

2.memory:封装了bigcache,主要用于应用本地缓存(例如:鉴权的用户权限信息缓存)和数据库mock(用于mock数据库操作行为)。

使用示例:

func Init(conf *Config) {
	auth = &client{
		conf:       conf,
		httpClient: http.DefaultClient,
		cache:      memory.NewCache(conf.Cache),
	}
	permissions, err = auth.cache.Get(userId)
	auth.cache.Set(userId, permissions)
}

注:在使用memory库进行初始化的时候,配置的分片数需要是2的幂次方

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL