redis

package
v0.0.0-...-bb76407 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var New = func(cfg config.Redis, log *logger.Logger) (*Redis, error) {
	db := redisClient.NewClient(&redisClient.Options{
		Addr:         fmt.Sprintf("%s:%d", cfg.Host, cfg.Port),
		Password:     cfg.Password,
		DB:           cfg.DB,
		PoolSize:     100,
		MinIdleConns: 10,
		MaxRetries:   3,
		ReadTimeout:  2 * time.Second,
		WriteTimeout: 2 * time.Second,
	})

	return &Redis{
		db:     db,
		logger: log,
	}, nil
}

Functions

This section is empty.

Types

type Redis

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

func NewWithMockDB

func NewWithMockDB(db redisClient.Cmdable, log *logger.Logger) *Redis

func (*Redis) Close

func (d *Redis) Close() error

func (*Redis) FlushDB

func (d *Redis) FlushDB(ctx context.Context) (*redisClient.StatusCmd, error)

func (*Redis) Get

func (d *Redis) Get(ctx context.Context, key string) (*redisClient.StringCmd, error)

func (*Redis) GetRange

func (d *Redis) GetRange(ctx context.Context, key string, start, end int64) (*redisClient.StringCmd, error)

func (*Redis) Set

func (d *Redis) Set(ctx context.Context, key string, value any, expiration time.Duration) (*redisClient.StatusCmd, error)

func (*Redis) SetRange

func (d *Redis) SetRange(ctx context.Context, key string, offset int64, value string) (*redisClient.IntCmd, error)

func (*Redis) SetWithTTL

func (d *Redis) SetWithTTL(ctx context.Context, key string, value any) (*redisClient.StatusCmd, error)

type RedisInterface

type RedisInterface interface {
	Close() error
	Get(ctx context.Context, key string) (*redisClient.StringCmd, error)
	Set(ctx context.Context, key string, value any, expiration time.Duration) (*redisClient.StatusCmd, error)
	GetRange(ctx context.Context, key string, start, end int64) (*redisClient.StringCmd, error)
	SetRange(ctx context.Context, key string, offset int64, value string) (*redisClient.IntCmd, error)
	FlushDB(ctx context.Context) (*redisClient.StatusCmd, error)
	SetWithTTL(ctx context.Context, key string, value any) (*redisClient.StatusCmd, error)
}

Jump to

Keyboard shortcuts

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