cache

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemCache

type MemCache struct {
	C           *cache.Cache
	DefaultTime time.Duration // 默认过期时间
	CleanTime   time.Duration // 每 CleanTime时间清除一次过期项目
}

func NewCache

func NewCache(defaultTime, cleanTime time.Duration) *MemCache

NewCache 创建一个默认过期时间为 defaultTime 实际的缓存,每 cleanTime时间清除一次过期项目

func (*MemCache) Clear

func (mem *MemCache) Clear()

Clear 清除缓存

func (*MemCache) Delete

func (mem *MemCache) Delete(key string)

Delete 删除

func (*MemCache) Get

func (mem *MemCache) Get(key string) (interface{}, bool)

Get 获取缓存

func (*MemCache) GetAll

func (mem *MemCache) GetAll() map[string]cache.Item

GetAll 获取全部

func (*MemCache) Load

func (mem *MemCache) Load(filePath string) error

Load 加载持久化

func (*MemCache) Save

func (mem *MemCache) Save(filePath string) error

Save 持久化到文件

func (*MemCache) Set

func (mem *MemCache) Set(key string, value interface{}) error

Set 写入数据

func (*MemCache) SetExp

func (mem *MemCache) SetExp(key string, value interface{}, expiration time.Duration) error

SetExp 写入数据并设置过期时间

Jump to

Keyboard shortcuts

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