cache

package
v0.11.17 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

func Clear(cache Cache) error

Clear 清除缓存 参数: - cache: 缓存基础设施接口 返回值: - 错误

func Delete

func Delete(cache Cache, key string) error

Delete 删除缓存值 参数: - cache: 缓存基础设施接口 - key: 缓存的键 返回值: - 错误

func Get

func Get[T any](cache Cache, key string) (T, error)

Get 获取缓存值 泛型参数: - T: 缓存值类型 参数: - cache: 缓存基础设施接口 - key: 缓存的键 返回值: - 缓存值 - 错误

func GetAll

func GetAll(cache Cache) (map[string]string, error)

GetAll 获取所有缓存值 参数: - cache: 缓存基础设施接口 返回值: - 缓存值,value以string类型先返回 - 错误

func GetMulti

func GetMulti(cache Cache, keys []string) (map[string]string, error)

GetMulti 批量获取缓存值 参数: - cache: 缓存基础设施接口 - keys: 缓存的键(多个) 返回值: - 缓存值,value以string类型先返回 - 错误

func Set

func Set(cache Cache, key string, value any, expireSec int64) error

Set 设置缓存值 参数: - cache: 缓存基础设施接口 - key: 缓存的键 - value: 要设置的缓存值 - expireSec: 缓存过期时间,单位秒 返回值: - 错误

Types

type Cache

type Cache interface {
	// Set 设置缓存值
	Set(key string, value string, expireSec int64) error

	// Get 获取缓存值
	Get(key string) (string, error)

	// GetMulti 获取多个缓存值
	GetMulti(keys []string) (map[string]string, error)

	// GetAll 获取所有缓存值
	GetAll() (map[string]string, error)

	// Delete 删除缓存值
	Delete(key string) error

	// Clear 清除缓存
	Clear() error
}

Cache 缓存基础设施接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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