cache

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 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 CacheItem

type CacheItem[V any] struct {
	Value     V
	ExpiresAt time.Time
}

CacheItem holds a cached value with expiration

type TTLCache

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

TTLCache is a generic time-based cache with configurable TTL per key

func NewTTLCache

func NewTTLCache[K comparable, V any]() *TTLCache[K, V]

NewTTLCache creates a new TTL cache

func (*TTLCache[K, V]) CleanExpired

func (c *TTLCache[K, V]) CleanExpired()

CleanExpired removes expired items from the cache

func (*TTLCache[K, V]) Clear

func (c *TTLCache[K, V]) Clear()

Clear removes all items from the cache

func (*TTLCache[K, V]) Delete

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

Delete removes a value from the cache

func (*TTLCache[K, V]) Get

func (c *TTLCache[K, V]) Get(key K) (V, bool)

Get retrieves a value from the cache

func (*TTLCache[K, V]) Set

func (c *TTLCache[K, V]) Set(key K, value V, ttl time.Duration)

Set stores a value in the cache with a TTL

Jump to

Keyboard shortcuts

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