Skip to content
Node: lru-cachegithub.com/sahilkhaire/gox/cache

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.js
go
// sync.Map or lru cache library
go
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.

Back to cache package overview

MIT Licensed · Built for Node.js developers moving to Go