Documentation
¶
Overview ¶
cache/go_cache.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var SimpleTool = func(ctx *gin.Context) *Tool[any] { return NewCacheTool[any](ctx, caches, nil) }
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] interface { Get(key string) (T, error) Set(key string, value T, expiration time.Duration) error Delete(key string) error }
Cache 是一个通用的缓存接口,定义了基本的缓存操作
type GoCache ¶
type GoCache[T any] struct { // contains filtered or unexported fields }
GoCache 是 go-cache 的实现
func NewGoCache ¶
NewGoCache 创建一个新的 GoCache 实例 defaultExpiration: 默认过期时间 cleanupInterval: 清理间隔
type RedisCache ¶
RedisCache 是 Redis 的实现
var RedisInstance *RedisCache
func GetRedisInstance ¶
func GetRedisInstance() *RedisCache
func NewRedisCache ¶
func NewRedisCache(cfg RedisConfig) (*RedisCache, error)
NewRedisCache 创建一个新的 RedisCache 实例
func (*RedisCache) Get ¶
func (r *RedisCache) Get(key string) (interface{}, error)
Get 从 Redis 中获取数据
type RedisConfig ¶
RedisConfig holds the Redis configuration parameters
Click to show internal directories.
Click to hide internal directories.