cache

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCacheKeyPrefix = "dy.wx.cache."

Variables

View Source
var (
	ErrKeyExpired  = errors.New("key expired")
	ErrKeyNotExist = errors.New("key not exist")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	IsExist(key string) bool
	Get(key string) (string, error)
	Put(key string, value string, expiration time.Duration) error
	Delete(key string) error
	ClearAll() error
}

Cache 缓存接口

type MemoryCache

type MemoryCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MemoryCache 内存缓存

func NewMemoryCache

func NewMemoryCache() *MemoryCache

func (*MemoryCache) ClearAll

func (c *MemoryCache) ClearAll() error

ClearAll 清除所有缓存项

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(key string) error

Delete 删除删除项

func (*MemoryCache) Get

func (c *MemoryCache) Get(key string) (string, error)

Get 获取缓存项

func (*MemoryCache) IsExist

func (c *MemoryCache) IsExist(key string) bool

IsExist 缓存项是否存在

func (*MemoryCache) Put

func (c *MemoryCache) Put(key string, value string, expiration time.Duration) error

Put 设置缓存项

Jump to

Keyboard shortcuts

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