cache

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICache

type ICache interface {
	// Get 获取缓存,返回缓存数据的 json 字符串,ttl, 和错误
	Get(ctx context.Context, key string) (val string, ttl time.Duration, err error)
	// Pull 获取缓存,并删除缓存
	Pull(ctx context.Context, key string) (val string, err error)
	// Set 设置缓存
	Set(ctx context.Context, key string, val interface{}, expire time.Duration) error
	// Remember 如果缓存不存在,则通过 fun 函数获取数据,并缓存。该函数返回 缓存数据和错误
	Remember(ctx context.Context, key string, expire time.Duration, fun func(ctx context.Context) (interface{}, error)) (string, error)
	// Clear 清理缓存
	Clear(ctx context.Context, key string) error
}

func NewJson

func NewJson(nameSpace string, cacheManager *cache.Cache) ICache

func NewString

func NewString(nameSpace string, cacheManager *cache.Cache) ICache

Jump to

Keyboard shortcuts

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