Documentation
¶
Index ¶
- Constants
- Variables
- func NewCache(cli cache.Client, cacheOpts CacheOptions, cacheConfig *options.Options) cache.Cache
- type CacheOptions
- type Manager
- func (cm *Manager) Close() error
- func (cm *Manager) Configuration() *options.Options
- func (cm *Manager) Connect() error
- func (cm *Manager) Remove(cacheKeys ...string) error
- func (cm *Manager) Retrieve(cacheKey string) ([]byte, status.LookupStatus, error)
- func (cm *Manager) RetrieveReference(cacheKey string) (any, status.LookupStatus, error)
- func (cm *Manager) SetCloseDrainTimeout(d time.Duration)
- func (cm *Manager) Store(cacheKey string, byteData []byte, ttl time.Duration) error
- func (cm *Manager) StoreReference(cacheKey string, data cache.ReferenceObject, ttl time.Duration) error
Constants ¶
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 ¶
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 ¶
Types ¶
type CacheOptions ¶
type CacheOptions struct {
UseIndex bool
IndexCliOpts index.IndexedClientOptions
}
Provide initialization options to the Manager / cache.Cache creation
type Manager ¶
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
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 (*Manager) RetrieveReference ¶
func (*Manager) SetCloseDrainTimeout ¶ added in v2.0.2
SetCloseDrainTimeout overrides the hard timeout used by Close(). A zero or negative value resets to DefaultCloseDrainHardTimeout. Safe to call once during construction.