local

package
v0.0.0-...-b5054f1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheManager

type CacheManager struct {
	// contains filtered or unexported fields
}

func NewLocalCacheManager

func NewLocalCacheManager(redisClient redis.Cmdable) *CacheManager

func (*CacheManager) Delete

func (cm *CacheManager) Delete(ctx context.Context, keys ...string) error

Delete 从本地缓存和 Redis 中删除一个或多个键

func (*CacheManager) Get

func (cm *CacheManager) Get(ctx context.Context, key string, loader func() (interface{}, error), result interface{}) error

Get 从缓存中获取数据,如果缓存未命中,则调用 loader 加载数据并缓存

func (*CacheManager) Set

func (cm *CacheManager) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error

Set 缓存数据到本地缓存和 Redis

func (*CacheManager) SetEmptyCache

func (cm *CacheManager) SetEmptyCache(ctx context.Context, key string, ttl time.Duration) error

SetEmptyCache 缓存空对象,防止缓存穿透

Jump to

Keyboard shortcuts

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