freelru

package
v0.0.0-...-319d980 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package freelru is a wrapper around go-freelru.LRU with additional statistics embedded and can be used as a drop in replacement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRU

type LRU[K comparable, V any] struct {
	// contains filtered or unexported fields
}

LRU is a wrapper around go-freelru.LRU with additional statistics embedded.

func New

func New[K comparable, V any](capacity uint32, hash lru.HashKeyCallback[K]) (*LRU[K, V], error)

func (*LRU[K, V]) Add

func (c *LRU[K, V]) Add(key K, value V) (evicted bool)

func (*LRU[K, V]) Contains

func (c *LRU[K, V]) Contains(key K) (ok bool)

func (*LRU[K, V]) Get

func (c *LRU[K, V]) Get(key K) (value V, ok bool)

func (*LRU[K, V]) GetAndResetStatistics

func (c *LRU[K, V]) GetAndResetStatistics() Statistics

GetAndResetStatistics returns the internal statistics for this LRU and resets all values to 0.

func (*LRU[K, V]) Purge

func (c *LRU[K, V]) Purge()

func (*LRU[K, V]) Remove

func (c *LRU[K, V]) Remove(key K) (present bool)

type Statistics

type Statistics struct {
	// Number of times for a hit of a cache entry.
	Hit uint64
	// Number of times for a miss of a cache entry.
	Miss uint64
	// Number of elements that were added to the cache.
	Added uint64
	// Number of elements that were deleted from the cache.
	Deleted uint64
}

Jump to

Keyboard shortcuts

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