Documentation
¶
Overview ¶
Package openfromenv provides the supported cache constructor: a bounded in-process L1, an optional Redis L2 when GOBEYOND_CACHE_* is set, and the tag-bump watcher that drops local copies early when L2 is present.
It lives in a subpackage so cache can keep its Store interface free of an import cycle with cache/memstore and cache/redisstore.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
func Open(opts Options) (config *cache.RuntimeConfig, closeFn func() error, err error)
Open is OpenFromEnv with explicit options (tests, custom logger).
func OpenFromEnv ¶
func OpenFromEnv() (config *cache.RuntimeConfig, close func() error, err error)
OpenFromEnv builds the deployment cache assembly:
- bounded memstore L1 (default MaxEntries/MaxBytes/MaxTTL)
- redisstore.FromEnv — absent endpoint is success (L1-only)
- cache.Tiered(l1, l2)
- WatchTagBumps when L2 is present
The returned RuntimeConfig is ready for runtime.Config.Cache (BuildID is filled by runtime.New). Close cancels the tag-bump watcher and closes the Redis client when one was opened; it is safe to call more than once.
Types ¶
type Options ¶
type Options struct {
// Logger receives tiered-store warnings. slog.Default applies when nil.
Logger *slog.Logger
// Memstore overrides L1 bounds. The zero value uses memstore defaults.
Memstore memstore.Options
// Redis overrides redisstore.FromEnv fields. The zero value reads the
// GOBEYOND_CACHE_* environment entirely.
Redis redisstore.Options
}
Options configures Open. The zero value is the supported deployment default.