cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2025 License: MIT Imports: 2 Imported by: 0

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 {
	// Get retrieves the value of the item from the cache.
	Get(key K) (V, error)

	// Set stores the value of the item in the cache.
	Set(key K, value V) error

	// Delete removes the item from the cache.
	Delete(key K) error
}

Cache is a generic cache interface.

type Item

type Item[V any] struct {
	// contains filtered or unexported fields
}

Item represents a generic item in the cache.

type SimpleCache

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

SimpleCache is a simple cache implementation using a sync.Map.

func NewSimpleCache

func NewSimpleCache[K comparable, V any]() *SimpleCache[K, V]

NewSimpleCache creates a new SimpleCache.

func (*SimpleCache[K, V]) Delete

func (c *SimpleCache[K, V]) Delete(key K) error

Delete removes the item from the cache.

func (*SimpleCache[K, V]) Get

func (c *SimpleCache[K, V]) Get(key K) (val V, err error)

Get retrieves the value of the item from the cache.

func (*SimpleCache[K, V]) Set

func (c *SimpleCache[K, V]) Set(key K, value V) error

Set stores the value of the item in the cache.

Jump to

Keyboard shortcuts

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