cache

package
v1.2.24 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacherDriverRedis        = "redis"
	CacherDriverRedisCluster = "miniredis"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ICacher

type ICacher interface {
	IIntCacher
}

ICacher 缓存

func NewCache added in v1.2.22

func NewCache(c *conf.Cache) ICacher

NewCache new cache

func NewRedisCacher added in v1.0.2

func NewRedisCacher(cli *redis.Client) ICacher

NewRedisCacher creates a new redis cacher

func NewRedisCacherByMiniRedis added in v1.2.22

func NewRedisCacherByMiniRedis(cli *miniredis.Miniredis) ICacher

NewRedisCacherByMiniRedis creates a new redis cacher by mini redis

type ICloser added in v1.0.2

type ICloser interface {
	Close() error
	Client() *redis.Client
}

ICloser 关闭缓存

type IIntCacher added in v1.0.2

type IIntCacher interface {
	ICloser
	// IncMax 增加缓存值,如果超过max则返回max
	IncMax(ctx context.Context, key string, max int64, expiration time.Duration) (bool, error)
	// DecMin 减少缓存值,如果小于min则返回min
	DecMin(ctx context.Context, key string, min int64, expiration time.Duration) (bool, error)
}

IIntCacher 整数缓存

Jump to

Keyboard shortcuts

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