cache

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

cache

定义缓存cache接口

memory

内存缓存,实现了缓存cache接口。

  • 使用第三方库 github.com/bluele/gcache

redis

redis缓存,实现了缓存cache接口。

  • 使用第三方库 github.com/go-redis/redis

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobal

func SetGlobal(c Cache)

SetGlobal 设置全局缓存.

Types

type Cache

type Cache interface {
	ListKey(*ListKeyRequest) (*ListKeyResponse, error)
	// SetDefaultTTL 设置默认过期时间.
	SetDefaultTTL(ttl time.Duration)
	// Put 添加缓存, 并设置key的默认过期时间.
	Put(key string, val interface{}) error
	// PutWithTTL 添加缓存, 并指定过期时间.
	PutWithTTL(key string, val interface{}, ttl time.Duration) error
	// Get 通过key获取缓存.
	Get(key string, val interface{}) error
	// Delete 通过key删除缓存.
	Delete(key string) error
	// IsExist 检查名为key的缓存是否存在.
	IsExist(key string) bool
	// ClearAll 清理所有缓存.
	ClearAll() error
	// Incr 增加名为key的缓存的值, 和count类似.
	Incr(key string) error
	// Decr 减少名为key的缓存的值, 和count类似.
	Decr(key string) error
	// Close 关闭缓存.
	Close() error
	// 携带上下文
	WithContext(ctx context.Context) Cache
}

Cache 缓存接口.

func C

func C() Cache

C 全局缓存对象, 默认使用.

type ListKeyRequest

type ListKeyRequest struct {
	*request.PageRequest
	// contains filtered or unexported fields
}

ListKeyRequest todo

func NewListKeyRequest

func NewListKeyRequest(pattern string, ps uint, pn uint) *ListKeyRequest

NewListKeyRequest todo

func (*ListKeyRequest) Pattern

func (req *ListKeyRequest) Pattern() string

Pattern tood

type ListKeyResponse

type ListKeyResponse struct {
	Keys  []string
	Total uint64
}

ListKeyResponse todo

func NewListKeyResponse

func NewListKeyResponse(keys []string, total uint64) *ListKeyResponse

NewListKeyResponse todo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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