cacheMode

package
v0.0.0-...-ea31202 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 8 Imported by: 0

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 (e *Entry) SetExpiryTimes(expiryTimes int64) error

func (*Entry) SetKey

func (e *Entry) SetKey(key string)

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) Close

func (c *ModeFIFO) Close()

func (*ModeFIFO) GetEntry

func (c *ModeFIFO) GetEntry() *Entry

func (*ModeFIFO) PopEntry

func (c *ModeFIFO) PopEntry() <-chan *Entry

func (*ModeFIFO) PushEntry

func (c *ModeFIFO) PushEntry() chan<- *Entry

func (*ModeFIFO) PutEntry

func (c *ModeFIFO) PutEntry(e *Entry)

func (*ModeFIFO) SetMaxMemUsed

func (c *ModeFIFO) SetMaxMemUsed(maxMem uintptr)

func (*ModeFIFO) Start

func (m *ModeFIFO) Start()

type Node

type Node struct {
	Pre  *Node
	Next *Node
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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