manager

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCloseDrainHardTimeout = 30 * time.Second

DefaultCloseDrainHardTimeout is the absolute upper bound a draining Close() will wait for in-flight cache operations before invoking the underlying client Close anyway. Prevents one stuck request from blocking reload forever.

Variables

View Source
var ErrCacheClosed = errors.New("cache is closed")

ErrCacheClosed is returned by Store/Retrieve/Remove when invoked after Close() has started draining. Handlers should treat this as a transient failure (config reload in progress) and respond to the client without touching the cache.

Functions

func NewCache

func NewCache(cli cache.Client, cacheOpts CacheOptions, cacheConfig *options.Options) cache.Cache

Types

type CacheOptions

type CacheOptions struct {
	UseIndex     bool
	IndexCliOpts index.IndexedClientOptions
}

Provide initialization options to the Manager / cache.Cache creation

type Manager

type Manager struct {
	cache.Client
	// contains filtered or unexported fields
}

Manager implements the cache.Cache interface for Trickster, providing an abstracted cache layer with metrics, locking, and optional index / LRU-key-reaper.

Manager also tracks in-flight Store/Retrieve/Remove operations so that Close() can drain them before tearing down the underlying client. This is the reload-safety contract: when the daemon replaces a cache instance on config reload, Close() on the old Manager blocks until handlers that still hold a reference have finished, with a hard timeout fallback so a single stuck request can't block reload forever.

func (*Manager) Close added in v2.0.2

func (cm *Manager) Close() error

Close marks the Manager as closing, waits for in-flight cache operations to drain, then closes the underlying client. The drain wait is bounded by closeDrainTimeout (default DefaultCloseDrainHardTimeout); if it elapses the underlying Close is invoked anyway so reload cannot hang.

Subsequent Store/Retrieve/Remove calls return ErrCacheClosed without touching the underlying client. Close is safe to call once; further calls no-op the drain and forward to the client.

func (*Manager) Configuration

func (cm *Manager) Configuration() *options.Options

func (*Manager) Connect

func (cm *Manager) Connect() error

func (*Manager) Remove

func (cm *Manager) Remove(cacheKeys ...string) error

func (*Manager) Retrieve

func (cm *Manager) Retrieve(cacheKey string) ([]byte, status.LookupStatus, error)

func (*Manager) RetrieveReference

func (cm *Manager) RetrieveReference(cacheKey string) (any, status.LookupStatus, error)

func (*Manager) SetCloseDrainTimeout added in v2.0.2

func (cm *Manager) SetCloseDrainTimeout(d time.Duration)

SetCloseDrainTimeout overrides the hard timeout used by Close(). A zero or negative value resets to DefaultCloseDrainHardTimeout. Safe to call once during construction.

func (*Manager) Store

func (cm *Manager) Store(cacheKey string, byteData []byte, ttl time.Duration) error

func (*Manager) StoreReference

func (cm *Manager) StoreReference(cacheKey string, data cache.ReferenceObject, ttl time.Duration) error

Jump to

Keyboard shortcuts

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