cache

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LFUCache

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

LFUCache is a least frequently used cache

func NewLFUCache

func NewLFUCache(size int) *LFUCache

NewLFUCache returns a LFUCache with the given size

func (*LFUCache) GetRecord

func (c *LFUCache) GetRecord(cid cid.Cid) *Record

GetRecord returns the Record for the given cid

func (*LFUCache) Keys

func (c *LFUCache) Keys() []cid.Cid

Keys returns all the cids in the cache

func (*LFUCache) Put

func (c *LFUCache) Put(cid cid.Cid)

Put adds a cid to the cache

type MockCache

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

MockCache stores up to size elements, randomly evicting when size is reached

func NewMockCache

func NewMockCache(size int) *MockCache

NewMockCache returns a MockCache with the given size

func (*MockCache) GetRecord

func (c *MockCache) GetRecord(cid.Cid) *Record

func (*MockCache) Keys

func (c *MockCache) Keys() []cid.Cid

func (*MockCache) Put

func (c *MockCache) Put(cid cid.Cid)

type Record

type Record struct {
	Frequency     int
	LastAccessed  time.Time
	InsertionTime time.Time
}

Jump to

Keyboard shortcuts

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