cache

package
v9.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cache provides lightweight, concurrency-safe in-memory caches used by RADIUS protocol hot paths.

The package currently exposes a generic TTL cache that stores entries by string key, evicts expired entries lazily, and bounds memory growth with a configurable maximum entry count.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TTLCache

type TTLCache[T any] struct {
	// contains filtered or unexported fields
}

TTLCache provides a minimal, concurrency-safe cache with a fixed TTL per entry.

func NewTTLCache

func NewTTLCache[T any](ttl time.Duration, maxEntries int) *TTLCache[T]

NewTTLCache creates a TTL-bound cache. maxEntries <= 0 falls back to 1.

func (*TTLCache[T]) Clear

func (c *TTLCache[T]) Clear()

Clear drops all cached entries.

func (*TTLCache[T]) Delete

func (c *TTLCache[T]) Delete(key string)

Delete removes a specific key from the cache.

func (*TTLCache[T]) Get

func (c *TTLCache[T]) Get(key string) (T, bool)

Get retrieves a value if present and not expired.

func (*TTLCache[T]) Set

func (c *TTLCache[T]) Set(key string, value T)

Set stores a value and evicts stale entries or random survivors when capacity is exceeded.

Jump to

Keyboard shortcuts

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