cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToFlagStruct

func ConvertToFlagStruct(
	loadedFlags []byte,
	fileFormat string,
) (map[string]dto.DTO, error)

Types

type Cache

type Cache interface {

	// Copy return a copy version of the cache.
	Copy() Cache

	// All return the complete list of the flags, as deep copies the caller is free to change.
	All() map[string]flag.Flag

	// Init allow to initialize the cache with a collection of flags.
	Init(flags map[string]dto.DTO)
	// contains filtered or unexported methods
}

Cache is the interface to represent a cache in the system.

type InMemoryCache

type InMemoryCache struct {
	// Flags are the flags by key. A flag of the map is shared by every reader: it must be treated
	// as read-only once it is in the map.
	Flags  map[string]*flag.InternalFlag
	Logger *fflog.FFLogger
	// Service validates the flags that are added, and keeps the parses of their queries.
	Service *flag.Service
}

func NewInMemoryCache

func NewInMemoryCache(svc *flag.Service, logger *fflog.FFLogger) *InMemoryCache

NewInMemoryCache creates an empty cache, which validates its flags with svc.

func (*InMemoryCache) All

func (fc *InMemoryCache) All() map[string]flag.Flag

All returns a snapshot of the flags: every flag is a deep copy of the cached one, so the caller can keep the map and change its flags, at any depth, without affecting the cache. The copy is not free: the evaluations read the flags with getFlag or shared, which do not copy.

func (*InMemoryCache) Copy

func (fc *InMemoryCache) Copy() Cache

func (*InMemoryCache) Init

func (fc *InMemoryCache) Init(flags map[string]dto.DTO)

type Manager

type Manager interface {
	UpdateCache(newFlags map[string]dto.DTO, log *fflog.FFLogger, notifyChanges bool) error
	Close()
	GetFlag(key string) (flag.Flag, error)
	// AllFlags returns a snapshot of the flags that the caller is free to change.
	AllFlags() (map[string]flag.Flag, error)
	// AllFlagsReadOnly returns the flags of the cache without copying them (cheap): the caller must only
	// read them, and must not keep them or hand them to code that does not.
	AllFlagsReadOnly() (map[string]flag.Flag, error)
	GetLatestUpdateDate() time.Time
}

func New

func New(
	notificationService notification.Service,
	persistentFlagConfigurationFile string,
	logger *fflog.FFLogger,
	opts ...Option,
) Manager

type Option

type Option func(*cacheManagerImpl)

Option customizes the Manager that New creates.

func WithService

func WithService(svc *flag.Service) Option

WithService makes the manager validate its flags with svc, which the caller owns (and closes). By default the manager creates a Service of its own.

Jump to

Keyboard shortcuts

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