Cache
Overview
Cache is a thread-safe LRU cache with per-key TTL.
Part of the cache package — Node.js analog: lru-cache.
Cache is a type exported by gox. Methods on this type are documented separately.
Signature
go
type Cache struct {
// contains filtered or unexported fields
}Compare: Node.js · Standard Go · gox
js
// Typical lru-cache pattern in Node.jsgo
// sync.Map or lru cache librarygo
import "github.com/sahilkhaire/gox/cache"
c := cache.New(500)
c.Set("user:1", user, time.Minute)Example
go
import "github.com/sahilkhaire/gox/cache"
c := cache.New(500)
c.Set("user:1", user, time.Minute)Tips
Browse methods on this type in the sidebar for handler-style APIs and options structs.
Standard library alternative
gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.