golazy.dev
–
golazy.dev
/
lazycache
/
inmemorycache
Index
|
Files
package inmemorycache
import "golazy.dev/lazycache/inmemorycache"
Functions
func New
New creates an in-memory lazycache backend.
func New(options Options) (lazycache.Backend, error)
Types
type Algorithm
Algorithm names the eviction algorithm used by the cache.
type Algorithm string
type Cache
type Cache struct {
// contains filtered or unexported fields
}
func (c *Cache) Get
Get returns a value by key.
func (c *Cache) Get(key string) (any, error)
func (c *Cache) Keys
Keys returns a stable snapshot of stored keys.
func (c *Cache) Keys() []string
func (c *Cache) Set
Set stores value by key.
func (c *Cache) Set(key string, value any) error
func (c *Cache) Stats
Stats returns a point-in-time statistics snapshot.
func (c *Cache) Stats() lazycache.Stats
type Options
Options configures an in-memory cache backend.
type Options struct {
Algorithm Algorithm
MaxEntries int
}
Package inmemorycache provides the default in-process lazycache backend.
lazyapp uses this package when an application does not configure another cache backend. Direct use is appropriate for tests, single-process apps, or custom lazycache setup that wants the same LRU implementation.