cache

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCustomOptions

func WithCustomOptions(customOptions CustomOptions) func(options *Options)

WithCustomOptions configures custom manager options

func WithLocalOptions

func WithLocalOptions(localOptions LocalOptions) func(options *Options)

WithLocalOptions configures local options for manager

func WithRedisOptions

func WithRedisOptions(redisOptions RedisOptions) func(options *Options)

WithRedisOptions configures redis options for manager

Types

type CampaignCache

type CampaignCache struct {
	VariationGroupID string
	VariationID      string
	FlagKeys         []string
}

CampaignCache expresses the campaign cache object to be saved for a visitor

type CustomManager

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

CustomManager represents the local db manager object

func (*CustomManager) Get

func (m *CustomManager) Get(visitorID string) (cache map[string]*CampaignCache, err error)

Get returns the campaigns in cache for this visitor

func (*CustomManager) Set

func (m *CustomManager) Set(visitorID string, campaignCache map[string]*CampaignCache) (err error)

Set saves the campaigns in cache for this visitor

type CustomOptions

type CustomOptions struct {
	Getter func(visitorID string) (map[string]*CampaignCache, error)
	Setter func(visitorID string, campaignCache map[string]*CampaignCache) error
}

CustomOptions are the options necessary to make the local cache manager work

type LocalDBManager

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

LocalDBManager represents the local db manager object

func (*LocalDBManager) Dispose

func (m *LocalDBManager) Dispose() error

Dispose frees IO resources

func (*LocalDBManager) Get

func (m *LocalDBManager) Get(visitorID string) (map[string]*CampaignCache, error)

Get returns the campaigns in cache for this visitor

func (*LocalDBManager) Set

func (m *LocalDBManager) Set(visitorID string, campaignCache map[string]*CampaignCache) error

Set saves the campaigns in cache for this visitor

type LocalOptions

type LocalOptions struct {
	DbPath string
}

LocalOptions are the options necessary to make the local cache manager work

type Manager

type Manager interface {
	Set(visitorID string, campaignInfos map[string]*CampaignCache) error
	Get(visitorID string) (map[string]*CampaignCache, error)
}

Manager is the interface that exposes cache manager functions

func InitManager

func InitManager(optionsFunc ...OptionBuilder) (manager Manager, err error)

InitManager initialize the manager with a type and options

type ManagerType

type ManagerType string

ManagerType represents infrastructure types of cache manager

const (
	// Local is a local database based cache manager
	Local ManagerType = "local"
	// Redis is a redis based cache manager
	Redis ManagerType = "redis"
	// Custom is a custom based cache manager that requires set / get implementation
	Custom ManagerType = "custom"
)

type OptionBuilder

type OptionBuilder func(*Options)

OptionBuilder is a func type to set options to the FlagshipOption.

type Options

type Options struct {
	RedisOptions
	LocalOptions
	CustomOptions
	// contains filtered or unexported fields
}

Options expresses all the possible options for cache manager

type RedisManager

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

RedisManager represents a redis db manager object

func (*RedisManager) Get

func (m *RedisManager) Get(visitorID string) (cache map[string]*CampaignCache, err error)

Get returns the campaigns in cache for this visitor

func (*RedisManager) Set

func (m *RedisManager) Set(visitorID string, campaignCache map[string]*CampaignCache) (err error)

Set saves the campaigns in cache for this visitor

type RedisOptions

type RedisOptions struct {
	Host      string
	Username  string
	Password  string
	TLSConfig *tls.Config
	Db        int
}

RedisOptions are the options necessary to make redis cache manager work

Jump to

Keyboard shortcuts

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