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 创建缓存
@param defaultExpiration 缓存项的默认过期时间 @param cleanupInterval 清理过期缓存项的时间间隔 0不清理 非0间隔清理 @param findingCallback Get缓存不存在时,主动查找回调方法 @return *Caches[T]
Click to show internal directories.
Click to hide internal directories.