lrucache

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: ISC Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRUCache

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

LRUCache is a least-recently-used cache for any type that's able to be indexed by Hash

func New

func New(capacity int, preallocate bool) *LRUCache

New creates a new LRUCache

func (*LRUCache) Add

func (c *LRUCache) Add(key *hash.Hash, value interface{})

Add adds an entry to the LRUCache

func (*LRUCache) Get

func (c *LRUCache) Get(key *hash.Hash) (interface{}, bool)

Get returns the entry for the given key, or (nil, false) otherwise

func (*LRUCache) Has

func (c *LRUCache) Has(key *hash.Hash) bool

Has returns whether the LRUCache contains the given key

func (*LRUCache) Remove

func (c *LRUCache) Remove(key *hash.Hash)

Remove removes the entry for the the given key. Does nothing if the entry does not exist

type LRUIDCache

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

func NewLRUIDCache

func NewLRUIDCache(capacity int, preallocate bool) *LRUIDCache

func (*LRUIDCache) Add

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

func (*LRUIDCache) Get

func (c *LRUIDCache) Get(key uint64) (interface{}, bool)

func (*LRUIDCache) Has

func (c *LRUIDCache) Has(key uint64) bool

func (*LRUIDCache) Remove

func (c *LRUIDCache) Remove(key uint64)

Jump to

Keyboard shortcuts

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