lru

package
v0.0.0-...-d436db8 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_CACHE_SLOT_NUM = 10
	DEFAULT_CACHE_CAP      = 1000 // 容量
	DEFAULT_CACHE_EXPIRE   = 3600 // 毫秒
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(slotNum int, cap int, expire time.Duration) *Cache

func (*Cache) Add

func (c *Cache) Add(key interface{}, value interface{})

func (*Cache) Clean

func (c *Cache) Clean()

func (*Cache) Del

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

func (*Cache) Get

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

func (*Cache) Stat

func (c *Cache) Stat() []map[string]uint64

func (*Cache) UpdateConfig

func (c *Cache) UpdateConfig(slotNum, cap int, expire time.Duration)

更新配置

type Node

type Node struct {
	Key, Value interface{}
	Time       time.Time
}

type Slot

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

func NewSlot

func NewSlot(cap int, expire time.Duration) *Slot

func (*Slot) Add

func (s *Slot) Add(key interface{}, value interface{})

func (*Slot) Clean

func (s *Slot) Clean()

func (*Slot) Del

func (s *Slot) Del(key interface{}) (exist bool)

func (*Slot) Get

func (s *Slot) Get(key interface{}) (value interface{}, exist bool)

func (*Slot) Len

func (s *Slot) Len() int

func (*Slot) RemoveLast

func (s *Slot) RemoveLast()

func (*Slot) UpdateConfig

func (s *Slot) UpdateConfig(cap int, expire time.Duration)

Jump to

Keyboard shortcuts

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