Documentation
¶
Index ¶
- type Cache
- type CachedStore
- func (cs *CachedStore) Close() error
- func (cs *CachedStore) Delete(ctx context.Context, key string) error
- func (cs *CachedStore) Get(ctx context.Context, key string) (*core.FeatureFlag, error)
- func (cs *CachedStore) GetAll(ctx context.Context) ([]core.FeatureFlag, error)
- func (cs *CachedStore) HealthCheck(ctx context.Context) error
- func (cs *CachedStore) Set(ctx context.Context, flag core.FeatureFlag) error
- type EvictionCallback
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 an in-memory cache with TTL and LRU eviction
func NewCacheWithEvictionCallback ¶
func NewCacheWithEvictionCallback(maxSize int, ttl time.Duration, callback EvictionCallback) *Cache
NewCacheWithEvictionCallback creates a new cache with eviction callback
func (*Cache) Get ¶
func (c *Cache) Get(key string) (*core.FeatureFlag, bool)
Get retrieves a feature flag from the cache Optimized for read-heavy workloads with minimal lock contention
type CachedStore ¶
type CachedStore struct {
// contains filtered or unexported fields
}
CachedStore wraps any Store implementation with an in-memory cache
func NewStore ¶
func NewStore(store core.Store, cacheConfig config.CacheConfig) *CachedStore
NewCachedStore creates a new cached store wrapper
func NewStoreWithMetrics ¶
func NewStoreWithMetrics(store core.Store, cacheConfig config.CacheConfig, metrics observability.MetricsCollector) *CachedStore
NewCachedStoreWithMetrics creates a new cached store wrapper with metrics
func (*CachedStore) Close ¶
func (cs *CachedStore) Close() error
Close cleanly shuts down both cache and store
func (*CachedStore) Delete ¶
func (cs *CachedStore) Delete(ctx context.Context, key string) error
Delete removes a feature flag from both cache and store
func (*CachedStore) Get ¶
func (cs *CachedStore) Get(ctx context.Context, key string) (*core.FeatureFlag, error)
Get retrieves a feature flag, checking cache first
func (*CachedStore) GetAll ¶
func (cs *CachedStore) GetAll(ctx context.Context) ([]core.FeatureFlag, error)
GetAll retrieves all feature flags from the underlying store Note: This bypasses cache for consistency and performance reasons
func (*CachedStore) HealthCheck ¶
func (cs *CachedStore) HealthCheck(ctx context.Context) error
HealthCheck verifies connectivity of the underlying store
func (*CachedStore) Set ¶
func (cs *CachedStore) Set(ctx context.Context, flag core.FeatureFlag) error
Set creates or updates a feature flag in both cache and store
type EvictionCallback ¶
type EvictionCallback func(key string, flag *core.FeatureFlag)
EvictionCallback is called when an item is evicted from the cache