cache

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 3 Imported by: 0

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)
	// SetTTL set default ttl
	SetDefaultTTL(ttl time.Duration)
	// set cached value with key and expire time.
	Put(key string, val interface{}) error
	// set cached value with key and expire time.
	PutWithTTL(key string, val interface{}, ttl time.Duration) error
	// get cached value by key.
	Get(key string, val interface{}) error
	// delete cached value by key.
	Delete(key string) error
	// check if cached value exists or not.
	IsExist(key string) bool
	// clear all cache.
	ClearAll() error
	// increase cached int value by key, as a counter.
	Incr(key string) error
	// decrease cached int value by key, as a counter.
	Decr(key string) error
	// close cache
	Close() error
	// 携带上下文
	WithContext(ctx context.Context) Cache
}

Cache provides the interface for cache implementations.

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