Documentation ¶
Index ¶
- Constants
- Variables
- func New[T any](config *Config, appConfig *app.Config, informer logger.Informer, ...) (cache.CacheInterface[T], error)
- func NewWithConfigurator[T any](config *Config, configurator configurator.Configurator, appConfig *app.Config, ...) (cache.CacheInterface[T], error)
- type Config
- type ReConfiguration
- func NewReConfiguration(informer logger.Informer, appConfig *app.Config, container container.Container, ...) (*ReConfiguration[[]byte], error)
- func NewReConfigurationWithConfigurator(informer logger.Informer, appConfig *app.Config, container container.Container, ...) (*ReConfiguration[[]byte], error)
- func (reConfiguration *ReConfiguration[T]) Cache() cache.CacheInterface[T]
- func (reConfiguration *ReConfiguration[T]) Clear(ctx context.Context) error
- func (reConfiguration *ReConfiguration[T]) Delete(ctx context.Context, key any) error
- func (reConfiguration *ReConfiguration[T]) Get(ctx context.Context, key any) (T, error)
- func (reConfiguration *ReConfiguration[T]) GetType() string
- func (reConfiguration *ReConfiguration[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
- func (reConfiguration *ReConfiguration[T]) ReConfiguration(c configurator.Configurator) error
- func (reConfiguration *ReConfiguration[T]) Set(ctx context.Context, key any, object T, options ...store.Option) error
Constants ¶
View Source
const ( DriverFieldName = "cache.driver" ExpirationFieldName = "cache.expiration" GoCacheDriver = "app" RedisDriver = "redis" MemcachedDriver = "memcached" DriverDefault = GoCacheDriver ExpirationDefault = 5 * time.Minute )
Variables ¶
View Source
var Component = &app.Component{ Dependencies: app.Components{ logger.Component, configurator.Component, reConfiguration.Component, gocache.Component, memcached.Component, redis.Component, }, Constructor: app.Constructor(func(container container.Container) error { return container.Provides( NewConfig, NewReConfigurationWithConfigurator, func(reConfiguration *ReConfiguration[[]byte]) cache.CacheInterface[[]byte] { return reConfiguration }, ) }), BindFlags: app.BindFlags(func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config) { flagSet.StringVar(&config.Driver, DriverFieldName, DriverDefault, fmt.Sprintf( "cache driver. Available drivers: "+ "%s - stores data in application memory; "+ "%s - stores data in redis; "+ "%s - stores data in memcached.", GoCacheDriver, RedisDriver, MemcachedDriver, )) flagSet.DurationVar(&config.Expiration, ExpirationFieldName, ExpirationDefault, "default data retention time") }) }), Run: app.Run(func(container container.Container) error { return container.Invoke(func( cache *ReConfiguration[[]byte], reConfiguration reConfiguration.ReConfiguration, informer logger.Informer, config *Config, ) { reConfiguration.Registration(cache) informer.Info("cache: registration in the reConfigurator") }) }), }
Functions ¶
func NewWithConfigurator ¶
func NewWithConfigurator[T any]( config *Config, configurator configurator.Configurator, appConfig *app.Config, informer logger.Informer, container container.Container, ) (cache.CacheInterface[T], error)
Types ¶
type Config ¶
func Configuration ¶
func Configuration(config *Config, configurator configurator.Configurator) *Config
type ReConfiguration ¶
type ReConfiguration[T any] struct { // contains filtered or unexported fields }
func NewReConfiguration ¶
func NewReConfigurationWithConfigurator ¶
func NewReConfigurationWithConfigurator(informer logger.Informer, appConfig *app.Config, container container.Container, config *Config, configurator configurator.Configurator) (*ReConfiguration[[]byte], error)
func (*ReConfiguration[T]) Cache ¶
func (reConfiguration *ReConfiguration[T]) Cache() cache.CacheInterface[T]
func (*ReConfiguration[T]) Clear ¶
func (reConfiguration *ReConfiguration[T]) Clear(ctx context.Context) error
func (*ReConfiguration[T]) Delete ¶
func (reConfiguration *ReConfiguration[T]) Delete(ctx context.Context, key any) error
func (*ReConfiguration[T]) Get ¶
func (reConfiguration *ReConfiguration[T]) Get(ctx context.Context, key any) (T, error)
func (*ReConfiguration[T]) GetType ¶
func (reConfiguration *ReConfiguration[T]) GetType() string
func (*ReConfiguration[T]) Invalidate ¶
func (reConfiguration *ReConfiguration[T]) Invalidate(ctx context.Context, options ...store.InvalidateOption) error
func (*ReConfiguration[T]) ReConfiguration ¶
func (reConfiguration *ReConfiguration[T]) ReConfiguration(c configurator.Configurator) error
Click to show internal directories.
Click to hide internal directories.