Documentation ¶
Index ¶
- func NewRedisClient(config *common_utils.BaseConfig) *redis.Client
- func NewRedisClientForTesting(config *common_utils.BaseConfig) *redis.Client
- type CacheSvc
- type CacheSvcImpl
- func (s *CacheSvcImpl) CloseClient() error
- func (s *CacheSvcImpl) Del(ctx context.Context, key string) error
- func (s *CacheSvcImpl) DelByPrefix(ctx context.Context, prefixName string)
- func (s *CacheSvcImpl) Get(ctx context.Context, key string, output any) error
- func (s *CacheSvcImpl) GetOrSet(ctx context.Context, key string, function func() any, ...) (any, error)
- func (s *CacheSvcImpl) Set(ctx context.Context, key string, data any, duration ...time.Duration) error
- type RedisClient
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) DelByPrefix ¶
func (s *CacheSvcImpl) DelByPrefix(ctx context.Context, prefixName string)
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 }
Click to show internal directories.
Click to hide internal directories.