cache

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func func(key string) (interface{}, error)

Func is the type of the function to memoize.

type ICache

type ICache interface {
	// Get looks up a key's value from the cache.
	Get(key interface{}) (value interface{}, ok bool)
	// Add adds a value to the cache.
	Add(key, value interface{})
	// Len returns the number of cached entries
	Len() int
	// Keys returns all the cached keys
	Keys() []interface{}
	// Remove is used to purge a key from the cache
	Remove(key interface{})
	// Purge is used to clear the cache
	Purge()
	// Contains is used to check if the cache contains a key
	// without updating recency or frequency.
	Contains(key interface{}) bool
	// Peek is used to inspect the cache value of a key
	// without updating recency or frequency.
	Peek(key interface{}) (value interface{}, ok bool)
}

LRU 接口

func NewICache

func NewICache(size int) (ICache, error)

type Memo

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

func New

func New(options ...MenoOption) *Memo

New returns a memoization of f. Clients must subsequently call Close.

func (*Memo) Close

func (memo *Memo) Close()

func (*Memo) Get

func (memo *Memo) Get(fname, key string) (interface{}, error)

type MenoOption

type MenoOption func(*Memo)

func MenoCallback

func MenoCallback(fname string, f Func) MenoOption

func MenoReqCount

func MenoReqCount(count int64) MenoOption

func MenoTimeout

func MenoTimeout(timeout time.Duration) MenoOption

Jump to

Keyboard shortcuts

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