qcache

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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]) Delete

func (c *Caches[T]) Delete(key string)

Delete

@Description: 删除缓存
@param key

func (*Caches[T]) Get

func (c *Caches[T]) Get(key string) (T, bool)

Get

@Description: 获取缓存
@param key
@return T

func (*Caches[T]) LoadFromFile

func (c *Caches[T]) LoadFromFile(filePath string) error

LoadFromFile

@Description: 从文件加载缓存
@param filePath 文件路径
@return error

func (*Caches[T]) SaveToFile

func (c *Caches[T]) SaveToFile(filePath string) error

SaveToFile

@Description: 将缓存保存到文件
@param filePath 文件路径
@return error

func (*Caches[T]) Set

func (c *Caches[T]) Set(key string, value T)

Set

@Description: 写入缓存,使用默认的缓存有效期
@param key
@param value
@param newExpiration

func (*Caches[T]) SetWithNewExpiration

func (c *Caches[T]) SetWithNewExpiration(key string, value T, newExpiration time.Duration)

SetWithNewExpiration

@Description: 写入缓存, 使用新的缓存有效期
@param key
@param value
@param newExpiration

Jump to

Keyboard shortcuts

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