base

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvictionCallback added in v0.2.0

type EvictionCallback[K comparable, V any] func(K, V)

type InMemoryCache

type InMemoryCache[K comparable, V any] interface {
	Set(key K, value V)
	Has(key K) bool
	Get(key K) (V, bool)
	Peek(key K) (V, bool)
	Keys() []K
	Values() []V
	Range(f func(K, V) bool)
	Delete(key K) bool
	Purge()

	// batching
	SetMany(items map[K]V)
	HasMany(keys []K) map[K]bool
	GetMany(keys []K) (map[K]V, []K)
	PeekMany(keys []K) (map[K]V, []K)
	DeleteMany(keys []K) map[K]bool

	// stats
	Capacity() int
	Algorithm() string
	Len() int
}

InMemoryCache represents a cache abstraction. The setters and getters does not return error, because the cache is in-memory. Remote cache such as Redis, Memcached, etc. should be implemented in a chain of loaders.

Jump to

Keyboard shortcuts

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