Documentation ¶
Index ¶
- type Caches
- func (c *Caches[T]) Delete(key string)
- func (c *Caches[T]) Get(key string) (T, bool)
- func (c *Caches[T]) LoadFromFile(filePath string) error
- func (c *Caches[T]) SaveToFile(filePath string) error
- func (c *Caches[T]) Set(key string, value T)
- func (c *Caches[T]) SetWithNewExpiration(key string, value T, newExpiration time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Caches ¶
type Caches[T any] struct { // contains filtered or unexported fields }
func NewCaches ¶
func NewCaches[T any](defaultExpiration, cleanupInterval time.Duration, findingCallback func(key string) (T, bool)) *Caches[T]
NewCaches
@Description: 创建缓存 @param defaultExpiration 默认有效期 @param cleanupInterval 清空间隔 @param findingCallback 缓存不存在时,主动查找回调 @return *Caches[T]
func (*Caches[T]) LoadFromFile ¶
LoadFromFile
@Description: 从文件加载缓存 @param filePath 文件路径 @return error
Click to show internal directories.
Click to hide internal directories.