Documentation ¶
Index ¶
- Constants
- func CastKeyToString(key interface{}) (string, error)
- func DdbBaseName(settings *Settings) string
- func GetConfigurableKey(name string) string
- func Marshal(v interface{}) ([]byte, error)
- func RedisBasename(settings *Settings) string
- func UniqKeys(keys []interface{}) ([]interface{}, error)
- func Unmarshal(data []byte, v interface{}) error
- type ChainConfiguration
- type ChainKvStore
- type DdbDeleteItem
- type DdbItem
- type DdbSettings
- type ElementFactory
- type Factory
- type InMemoryConfiguration
- type InMemoryKvStore
- func (s *InMemoryKvStore[T]) Contains(_ context.Context, key any) (bool, error)
- func (s *InMemoryKvStore[T]) Delete(_ context.Context, key any) error
- func (s *InMemoryKvStore[T]) DeleteBatch(ctx context.Context, keys any) error
- func (s *InMemoryKvStore[T]) EstimateSize() *int64
- func (s *InMemoryKvStore[T]) Get(_ context.Context, key any, value *T) (bool, error)
- func (s *InMemoryKvStore[T]) GetBatch(ctx context.Context, keys any, values any) ([]interface{}, error)
- func (s *InMemoryKvStore[T]) Put(_ context.Context, key any, value T) error
- func (s *InMemoryKvStore[T]) PutBatch(ctx context.Context, values any) error
- type InMemorySettings
- type KvStore
- func NewConfigurableKvStore[T any](ctx context.Context, config cfg.Config, logger log.Logger, name string) (KvStore[T], error)
- func NewDdbKvStore[T any](ctx context.Context, config cfg.Config, logger log.Logger, settings *Settings) (KvStore[T], error)
- func NewDdbKvStoreWithInterfaces[T any](repository ddb.Repository, settings *Settings) KvStore[T]
- func NewEmptyKvStore[T any]() KvStore[T]
- func NewEmptyKvStoreWithInterfaces[T any]() KvStore[T]
- func NewInMemoryKvStore[T any](_ context.Context, _ cfg.Config, _ log.Logger, settings *Settings) (KvStore[T], error)
- func NewInMemoryKvStoreWithInterfaces[T any](settings *Settings) KvStore[T]
- func NewMetricStoreWithInterfaces[T any](store KvStore[T], settings *Settings) KvStore[T]
- func NewRedisKvStore[T any](ctx context.Context, config cfg.Config, logger log.Logger, settings *Settings) (KvStore[T], error)
- func NewRedisKvStoreWithInterfaces[T any](client redis.Client, settings *Settings) KvStore[T]
- func ProvideConfigurableKvStore[T any](ctx context.Context, config cfg.Config, logger log.Logger, name string) (KvStore[T], error)
- type MetricStore
- func (s *MetricStore[T]) Contains(ctx context.Context, key any) (bool, error)
- func (s *MetricStore[T]) Delete(ctx context.Context, key any) error
- func (s *MetricStore[T]) DeleteBatch(ctx context.Context, keys any) error
- func (s *MetricStore[T]) Get(ctx context.Context, key any, value *T) (bool, error)
- func (s *MetricStore[T]) GetBatch(ctx context.Context, keys any, result any) ([]interface{}, error)
- func (s *MetricStore[T]) Put(ctx context.Context, key any, value T) error
- func (s *MetricStore[T]) PutBatch(ctx context.Context, values any) error
- type Settings
- type SizedStore
Constants ¶
View Source
const ( TypeChain = "chain" TypeDdb = "ddb" TypeInMemory = "inMemory" TypeRedis = "redis" )
Variables ¶
This section is empty.
Functions ¶
func CastKeyToString ¶
func DdbBaseName ¶
func GetConfigurableKey ¶
func RedisBasename ¶
Types ¶
type ChainConfiguration ¶
type ChainConfiguration struct { Project string `cfg:"project"` Family string `cfg:"family"` Group string `cfg:"group"` Application string `cfg:"application"` Type string `cfg:"type" default:"chain" validate:"eq=chain"` Elements []string `cfg:"elements" validate:"min=1"` Ddb DdbSettings `cfg:"ddb"` Ttl time.Duration `cfg:"ttl"` BatchSize int `cfg:"batch_size" default:"100" validate:"min=1"` MissingCacheEnabled bool `cfg:"missing_cache_enabled" default:"false"` MetricsEnabled bool `cfg:"metrics_enabled" default:"false"` InMemory InMemoryConfiguration `cfg:"in_memory"` }
type ChainKvStore ¶
type ChainKvStore[T any] interface { KvStore[T] Add(elementFactory ElementFactory[T]) error AddStore(store KvStore[T]) }
func NewChainKvStore ¶
type DdbDeleteItem ¶
type DdbDeleteItem struct {
Key string `json:"key" ddb:"key=hash"`
}
type DdbSettings ¶
type DdbSettings struct {
ClientName string `cfg:"client_name" default:"default"`
}
type ElementFactory ¶
type Factory ¶
type Factory[T any] func(elementFactory ElementFactory[T], settings *Settings) (KvStore[T], error)
type InMemoryConfiguration ¶
type InMemoryConfiguration struct { MaxSize int64 `cfg:"max_size" default:"5000"` Buckets uint32 `cfg:"buckets" default:"16"` ItemsToPrune uint32 `cfg:"items_to_prune" default:"500"` DeleteBuffer uint32 `cfg:"delete_buffer" default:"1024"` PromoteBuffer uint32 `cfg:"promote_buffer" default:"1024"` GetsPerPromote int32 `cfg:"gets_per_promote" default:"3"` }
type InMemoryKvStore ¶
type InMemoryKvStore[T any] struct { // contains filtered or unexported fields }
func (*InMemoryKvStore[T]) Delete ¶
func (s *InMemoryKvStore[T]) Delete(_ context.Context, key any) error
func (*InMemoryKvStore[T]) DeleteBatch ¶
func (s *InMemoryKvStore[T]) DeleteBatch(ctx context.Context, keys any) error
func (*InMemoryKvStore[T]) EstimateSize ¶
func (s *InMemoryKvStore[T]) EstimateSize() *int64
type InMemorySettings ¶
type KvStore ¶
type KvStore[T any] interface { // Check if a key exists in the store. Contains(ctx context.Context, key any) (bool, error) // Retrieve a value from the store by the given key. If the value does // not exist, false is returned and value is not modified. // value should be a pointer to the model you want to retrieve. Get(ctx context.Context, key any, value *T) (bool, error) // Retrieve a set of values from the store. Each value is written to the // map in values at its key. Values should be something which can be converted to map[interface{}]T. // Returns a list of missing keys in the store. GetBatch(ctx context.Context, keys any, values any) ([]any, error) // Write a value to the store Put(ctx context.Context, key any, value T) error // Write a batch of values to the store. Values should be something which // can be converted to map[interface{}]T. PutBatch(ctx context.Context, values any) error // Remove the value with the given key from the store Delete(ctx context.Context, key any) error // Remove all values with the given keys from the store DeleteBatch(ctx context.Context, keys any) error }
func NewConfigurableKvStore ¶
func NewDdbKvStore ¶
func NewDdbKvStoreWithInterfaces ¶
func NewDdbKvStoreWithInterfaces[T any](repository ddb.Repository, settings *Settings) KvStore[T]
func NewEmptyKvStore ¶
func NewInMemoryKvStore ¶
func NewRedisKvStore ¶
type MetricStore ¶
func (*MetricStore[T]) DeleteBatch ¶
func (s *MetricStore[T]) DeleteBatch(ctx context.Context, keys any) error
type Settings ¶
type Settings struct { cfg.AppId DdbSettings DdbSettings Name string Ttl time.Duration BatchSize int MetricsEnabled bool InMemorySettings }
type SizedStore ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.