cache

package
v0.0.9-beta Latest Latest
Warning

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

Go to latest
Published: Mar 15, 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 TTLCache

type TTLCache struct {
	// contains filtered or unexported fields
}

TTLCache is a simple in-memory cache with per-entry TTL expiry. Safe for concurrent use. Background goroutine evicts stale entries every 30s.

func New

func New() *TTLCache

New creates a new TTLCache and starts the background eviction loop.

func (*TTLCache) Delete

func (c *TTLCache) Delete(key string)

Delete removes a key immediately.

func (*TTLCache) Get

func (c *TTLCache) Get(key string) (interface{}, bool)

Get returns the cached value and true if it exists and has not expired.

func (*TTLCache) Set

func (c *TTLCache) Set(key string, value interface{}, ttl time.Duration)

Set stores value under key with the given TTL.

Jump to

Keyboard shortcuts

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