caches

package
v0.0.0-...-7647e70 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CacheOperationSet    = "set"
	CacheOperationDelete = "delete"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheFactory

type CacheFactory struct {
	// contains filtered or unexported fields
}

缓存集成器,用户让别的对象拥有使用缓存的能力

func (*CacheFactory) Cache

func (this *CacheFactory) Cache() *Factory

取得缓存管理器

type CacheOperation

type CacheOperation = string

操作类型

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

缓存管理器

func NewFactory

func NewFactory() *Factory

创建一个新的缓存管理器

func (*Factory) Close

func (this *Factory) Close()

关闭

func (*Factory) Delete

func (this *Factory) Delete(key string)

删除缓存

func (*Factory) Get

func (this *Factory) Get(key string) (value interface{}, found bool)

获取缓存

func (*Factory) Has

func (this *Factory) Has(key string) bool

判断是否有缓存

func (*Factory) OnOperation

func (this *Factory) OnOperation(f func(op CacheOperation, item *Item))

设置操作回调

func (*Factory) Reset

func (this *Factory) Reset()

重置状态

func (*Factory) Set

func (this *Factory) Set(key string, value interface{}, duration ...time.Duration) *Item

设置缓存

type Item

type Item struct {
	Key   string
	Value interface{}
	// contains filtered or unexported fields
}

缓存条目定义

func (*Item) Expire

func (this *Item) Expire(duration time.Duration) *Item

设置过期时长

func (*Item) ExpireAt

func (this *Item) ExpireAt(expireTime time.Time) *Item

设置过期时间

func (*Item) IsExpired

func (this *Item) IsExpired() bool

判断是否已过期

func (*Item) Set

func (this *Item) Set(value interface{}) *Item

设置值

Jump to

Keyboard shortcuts

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