memorycache

package
v0.0.0-...-40ef913 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(c *Cache)

Delete New()生成的Cache要Delete()才能彻底删除

func GC

func GC()

GC 清理过期的数据,需要手动调用,比如放到定时任务中 如果数据总量不多,建议懒得GC

Types

type Cache

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

Cache 缓存

func New

func New() (c *Cache)

New New

func (*Cache) Delete

func (c *Cache) Delete(key interface{})

Delete 删除

func (*Cache) Each

func (c *Cache) Each(f func(k, v interface{}) error) (err error)

Each 遍历,注意:只能读,不要写

func (*Cache) Exist

func (c *Cache) Exist(key interface{}) (is bool)

Exist 是否存在

func (*Cache) Get

func (c *Cache) Get(key interface{},
	f ...func(old interface{}) (v interface{}, t int64)) (v interface{})

Get 取缓存数据,如果不存在或过期就用 f() 创建 t: 有效时间,0永不过期,单位秒

func (*Cache) Set

func (c *Cache) Set(key interface{}, data interface{}, t int64)

Set 设置缓存数据 t: 有效时间,0永不过期,单位秒

func (*Cache) SetExpire

func (c *Cache) SetExpire(key interface{}, expire int64) bool

SetExpire 设置过期时间戳

Jump to

Keyboard shortcuts

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