Documentation
¶
Overview ¶
Copyright 2020 just-codeding-0 . All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.
Index ¶
Constants ¶
View Source
const ( HashMap storeType = 0 Set storeType = 1 )
View Source
const ( FIFO = iota // 0 First In First Out LRU // 1 Least Recently Used )
View Source
const ( B = 1 Kb = B * 1024 MB = Kb * 1024 GB = MB * 1024 )
View Source
const MaxExpiryPolicy = 60 * 60 * 24 * 30
Variables ¶
View Source
var (
InvalidExpiryTimes = errors.New("无效的到期时间")
)
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType uint8
const ( Save ActionType = 0 Get ActionType = 1 Delete ActionType = 2 )
type CacheElimination ¶
type CacheElimination interface { PushEntry() chan<- *Entry PopEntry() <-chan *Entry SetMaxMemUsed(maxMem uintptr) Close() Start() GetEntry() *Entry PutEntry(e *Entry) }
该接口会实现两个功能 1.往里面放entry 2.返回一个订阅的chan,该类会将需要淘汰的entry返回
<- f f <-
type Entry ¶
type Entry struct { Key string // key ExpiryTimes int64 // Timestamp StoreType storeType Action ActionType }
func (*Entry) SetAction ¶
func (e *Entry) SetAction(action ActionType)
func (*Entry) SetExpiryTimes ¶
func (*Entry) SetStoreType ¶
func (e *Entry) SetStoreType(storeType storeType)
type ModeFIFO ¶
type ModeFIFO struct {
// contains filtered or unexported fields
}
func NewModeFIFO ¶
func NewModeFIFO() *ModeFIFO
func (*ModeFIFO) SetMaxMemUsed ¶
func (c *ModeFIFO) SetMaxMemUsed(maxMem uintptr)
Click to show internal directories.
Click to hide internal directories.