types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 0 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] interface {
	// Set sets the value for the given key on cache.
	Set(key K, value V)

	// Get gets the value for the given key from cache.
	Get(key K) (value V, ok bool)

	// Remove removes the provided key from the cache.
	Remove(key K) (ok bool)

	// Contains check if a key exists in cache without updating the recent-ness
	Contains(key K) (ok bool)

	// Peek returns key's value without updating the recent-ness.
	Peek(key K) (value V, ok bool)

	// SetOnEvicted sets the callback function that will be called when an entry is evicted from the cache.
	SetOnEvicted(callback OnEvictCallback[K, V])

	// Len returns the number of entries in the cache.
	Len() int

	// Purge clears all cache entries
	Purge()

	// Close closes the cache and releases any resources associated with it.
	Close()
}

Cache is the interface for a cache.

type OnEvictCallback

type OnEvictCallback[K comparable, V any] func(key K, value V)

Jump to

Keyboard shortcuts

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