cache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTTL = 24 * time.Hour

DefaultTTL is the default time-to-live for cached flags. Matches the JS SDK's DEFAULT_CACHE_TTL (24 * 60 * 60 * 1000 ms).

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryCache

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

MemoryCache is a simple in-memory CacheAdapter with TTL. Safe for concurrent use.

func NewMemoryCache

func NewMemoryCache(ttl time.Duration) *MemoryCache

NewMemoryCache returns a new MemoryCache with the given TTL. Use DefaultTTL for the standard 24-hour TTL. A TTL of zero disables flag expiry.

func (*MemoryCache) LoadContext

func (m *MemoryCache) LoadContext(apiKey string) (*flagmint.EvaluationContext, error)

LoadContext returns the cached evaluation context for apiKey, or nil if none exists.

func (*MemoryCache) LoadFlags

func (m *MemoryCache) LoadFlags(apiKey string) (*flagmint.FeatureFlags, error)

LoadFlags returns the cached flags for apiKey, or nil if the entry is absent or has expired.

func (*MemoryCache) SaveContext

func (m *MemoryCache) SaveContext(apiKey string, ctx *flagmint.EvaluationContext) error

SaveContext persists the evaluation context for apiKey.

func (*MemoryCache) SaveFlags

func (m *MemoryCache) SaveFlags(apiKey string, flags flagmint.FeatureFlags) error

SaveFlags stores flags for apiKey, resetting the TTL timer.

type NopCache

type NopCache struct{}

NopCache is a no-op CacheAdapter that discards all writes and returns nil on all reads. Use it when caching is disabled.

func (NopCache) LoadContext

func (NopCache) LoadContext(_ string) (*flagmint.EvaluationContext, error)

LoadContext always returns nil, nil (cache miss).

func (NopCache) LoadFlags

func (NopCache) LoadFlags(_ string) (*flagmint.FeatureFlags, error)

LoadFlags always returns nil, nil (cache miss).

func (NopCache) SaveContext

func (NopCache) SaveContext(_ string, _ *flagmint.EvaluationContext) error

SaveContext discards the context without storing it.

func (NopCache) SaveFlags

func (NopCache) SaveFlags(_ string, _ flagmint.FeatureFlags) error

SaveFlags discards the flags without storing them.

Jump to

Keyboard shortcuts

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