redis_client

package
v1.0.26 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisClient

func NewRedisClient(config *common_utils.BaseConfig) *redis.Client

func NewRedisClientForTesting

func NewRedisClientForTesting(config *common_utils.BaseConfig) *redis.Client

Types

type CacheSvc

type CacheSvc interface {
	Set(ctx context.Context, key string, data any, duration ...time.Duration) error
	Get(ctx context.Context, key string, output any) error
	Del(ctx context.Context, key string) error
	DelByPrefix(ctx context.Context, prefixName string)
	GetOrSet(ctx context.Context, key string, function func() any, duration ...time.Duration) (any, error)
	CloseClient() error
}

func NewCacheSvc

func NewCacheSvc(config *common_utils.BaseConfig, cacheDb RedisClient) CacheSvc

type CacheSvcImpl

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

func (*CacheSvcImpl) CloseClient

func (s *CacheSvcImpl) CloseClient() error

func (*CacheSvcImpl) Del

func (s *CacheSvcImpl) Del(ctx context.Context, key string) error

func (*CacheSvcImpl) DelByPrefix

func (s *CacheSvcImpl) DelByPrefix(ctx context.Context, prefixName string)

func (*CacheSvcImpl) Get

func (s *CacheSvcImpl) Get(ctx context.Context, key string, output any) error

func (*CacheSvcImpl) GetOrSet

func (s *CacheSvcImpl) GetOrSet(ctx context.Context, key string, function func() any, duration ...time.Duration) (any, error)

func (*CacheSvcImpl) Set

func (s *CacheSvcImpl) Set(ctx context.Context, key string, data any, duration ...time.Duration) error

type RedisClient

type RedisClient interface {
	Get(ctx context.Context, key string) *redis.StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	Scan(ctx context.Context, cursor uint64, match string, count int64) *redis.ScanCmd
	Close() error
}

Jump to

Keyboard shortcuts

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