invcache

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: ISC Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InventoryCache

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

lruInventoryCache provides a concurrency safe cache that is limited to a maximum number of items with eviction for the oldest entry when the limit is exceeded.

func NewLruInventoryCache

func NewLruInventoryCache(limit uint) *InventoryCache

newLruInventoryCache returns a new inventory cache that is limited to the number of entries specified by limit. When the number of entries exceeds the limit, the oldest (least recently used) entry will be removed to make room for the new entry.

func (*InventoryCache) Add

func (m *InventoryCache) Add(iv *message.InvVect)

Add adds the passed inventory to the cache and handles eviction of the oldest item if adding the new item would exceed the max limit. Adding an existing item makes it the most recently used item.

This function is safe for concurrent access.

func (*InventoryCache) Delete

func (m *InventoryCache) Delete(iv *message.InvVect)

Delete deletes the passed inventory item from the cache (if it exists).

This function is safe for concurrent access.

func (*InventoryCache) Exists

func (m *InventoryCache) Exists(iv *message.InvVect) bool

Exists returns whether or not the passed inventory item is in the cache.

This function is safe for concurrent access.

func (*InventoryCache) String

func (m *InventoryCache) String() string

String returns the cache as a human-readable string.

This function is safe for concurrent access.

Jump to

Keyboard shortcuts

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