Registry / utility / go-pkgz-expirable-cache

go-pkgz-expirable-cache

JSON →
library1.0.0gogounverified

A thread-safe Go cache with TTL-based expiration and support for LRC/LRU eviction policies.

go get github.com/go-pkgz/expirable-cache
INSTALL
IMPORT
SIG · GO-PKGZ-EXPIRABLE-
G
go-pkgz-expirable-cache
utilitygov1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cache
github.com/go-pkgz/expirable-cache

Creates a cache with TTL and max keys, then sets and gets a value.

package main import ( "time" "github.com/go-pkgz/expirable-cache" ) func main() { c := cache.NewCache[string, string]().WithTTL(5 * time.Minute).WithMaxKeys(100) c.Set("key", "value") val, ok := c.Get("key") _, _ = val, ok }
Debug
Known issues
gotchaExpired entries are only removed on Set or explicit DeleteExpired; use a periodic ticker for reliable cleanup.
fix
Run cache.DeleteExpired periodically (e.g., every TTL/2) using time.Ticker.
affects: *
Upgrade
Version history
1.0.0latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
go-pkgz-expirable-cache — go get go-pkgz-expirable-cache · libregistry