cache

package
v1.0.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearExpireNode

func ClearExpireNode()

func Del

func Del(key string) bool

删除⼀个值

func Exists

func Exists(key string) bool

检测⼀个值 是否存在

func Flush

func Flush() bool

情况所有值

func Get

func Get(key string) (interface{}, bool)

func InitMCache

func InitMCache()

func Keys

func Keys() int64

返回所有的key 多少

func MStat

func MStat(t *testing.T)

func NewLinkedList

func NewLinkedList() *linkedList

func Set

func Set(key string, val interface{}, expire int64)

设置⼀一个缓存项,并且在expire时间之后过期

func SetMaxMemory

func SetMaxMemory(size string) bool

func TestGet

func TestGet(t *testing.T)

func TestSet

func TestSet(t *testing.T)

Types

type Cache

type Cache struct {
	SizeStr string //1KB,100KB,1MB,2MB,1GB

	Interval int // 多长时间执行一次清理任务,操作单位秒
	// contains filtered or unexported fields
}

func (*Cache) ClearExpireNode

func (c *Cache) ClearExpireNode()

func (*Cache) Del

func (c *Cache) Del(key string) bool

删除一个值

func (*Cache) Exists

func (c *Cache) Exists(key string) bool

检测一个值是否存在

func (*Cache) Flush

func (c *Cache) Flush() bool

清空所有值

func (*Cache) Get

func (c *Cache) Get(key string) (interface{}, bool)

func (*Cache) Keys

func (c *Cache) Keys() int64

返回所有的key 多少

func (*Cache) Set

func (c *Cache) Set(key string, val interface{}, expire time.Duration)

设置⼀一个缓存项,并且在expire时间之后过期

func (*Cache) SetMaxMemory

func (c *Cache) SetMaxMemory(size string) bool

type ICache

type ICache interface {
	//size 是⼀一个字符串串。⽀支持以下参数: 1KB,100KB,1MB,2MB,1GB 等
	SetMaxMemory(size string) bool
	// 设置⼀一个缓存项,并且在expire时间之后过期
	Set(key string, val interface{}, expire time.Duration) // 获取⼀一个值
	Get(key string) (interface{}, bool)
	// 删除⼀一个值
	Del(key string) bool
	// 检测⼀一个值 是否存在
	Exists(key string) bool
	// 情况所有值
	Flush() bool
	// 返回所有的key 多少
	Keys() int64
	//清理过期的节点
	ClearExpireNode()
}

func NewCache

func NewCache(size string, interval int) ICache

Jump to

Keyboard shortcuts

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