processcache

package
v3.1.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package processcache provides dependency-light process-local cache semantics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a goroutine-safe, process-local cache with TTL and list batching semantics.

func New

func New(maxEntries int, janitorPeriod time.Duration) *Cache

New constructs a process-local cache.

func (*Cache) Close

func (c *Cache) Close()

Close stops the background janitor.

func (*Cache) Delete

func (c *Cache) Delete(key string) bool

Delete removes key and reports whether it existed.

func (*Cache) Exists

func (c *Cache) Exists(key string) bool

Exists reports whether key is present and not expired.

func (*Cache) Flush

func (c *Cache) Flush()

Flush removes every entry.

func (*Cache) Get

func (c *Cache) Get(key string) (any, bool)

Get returns value when key is present and not expired.

func (*Cache) Keys

func (c *Cache) Keys() []string

Keys returns all non-expired keys.

func (*Cache) PopAll

func (c *Cache) PopAll(key string) []any

PopAll returns the list at key and removes it.

func (*Cache) Push

func (c *Cache) Push(key string, value any) int

Push appends value to the list at key and returns the new list length.

func (*Cache) Set

func (c *Cache) Set(key string, value any, ttl time.Duration)

Set stores value under key with an optional TTL.

func (*Cache) Size

func (c *Cache) Size() int

Size returns the number of non-expired entries.

func (*Cache) Update

func (c *Cache) Update(key string, updater func(any) any) any

Update stores updater's returned value atomically and returns it.

Jump to

Keyboard shortcuts

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