cache

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheKey

type CacheKey[T config.TenantId, V any] struct {
	EntityId  T
	Prefix    string
	ConfigKey string
}

func NewCacheKey

func NewCacheKey[T config.TenantId, V any](entityId T, opts ...CacheKeyOptions[T, V]) *CacheKey[T, V]

func (*CacheKey[T, V]) DefaultValue

func (c *CacheKey[T, V]) DefaultValue() string

type CacheKeyOptions

type CacheKeyOptions[T config.TenantId, V any] func(*CacheKey[T, V])

func WithCacheConfigKey

func WithCacheConfigKey[T config.TenantId, V any](configKey string) CacheKeyOptions[T, V]

func WithCacheKeyPrefix

func WithCacheKeyPrefix[T config.TenantId, V any](prefix string) CacheKeyOptions[T, V]

type ConfigRedisRepo

type ConfigRedisRepo[T config.TenantId, V any] struct {
	RNonClusteredClient *redis.Client
	ConfigDbRepo        configDb.IConfigDbRepo[T, V]
	TTL                 time.Duration
}

func RegisterConfigForCacheOps

func RegisterConfigForCacheOps[T config.TenantId, V any](client *redis.Client, configDbRepo configDb.IConfigDbRepo[T, V], ttl time.Duration) *ConfigRedisRepo[T, V]

func (*ConfigRedisRepo[T, V]) GetConfig

func (c *ConfigRedisRepo[T, V]) GetConfig(ctx context.Context, key string, entityId T) (*V, error)

func (*ConfigRedisRepo[T, V]) GetConfigByKeyForEntity

func (c *ConfigRedisRepo[T, V]) GetConfigByKeyForEntity(ctx context.Context, key string) (*V, error)

func (*ConfigRedisRepo[T, V]) IsConfigCacheKeyPresent

func (c *ConfigRedisRepo[T, V]) IsConfigCacheKeyPresent(ctx context.Context, key string) (bool, error)

func (*ConfigRedisRepo[T, V]) SaveConfig

func (c *ConfigRedisRepo[T, V]) SaveConfig(ctx context.Context, key string, config *V) error

type IConfigCacheRepo

type IConfigCacheRepo[T config.TenantId, V any] interface {
	SaveConfig(ctx context.Context, key string, config *V) error
	GetConfigByKeyForEntity(ctx context.Context, key string) (*V, error)
	GetConfig(ctx context.Context, key string, entityId T) (*V, error)
	IsConfigCacheKeyPresent(ctx context.Context, key string) (bool, error)
}

Jump to

Keyboard shortcuts

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