redisclient

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewRedisClient = func(opt *redis.Options) *redis.Client {
	return redis.NewClient(opt)
}

NewRedisClient is a variable wrapper around redis.NewClient so tests can override it.

Functions

This section is empty.

Types

type Client

type Client struct {
	Redis RedisCmdable
}

Client holds the Redis client instance (now interface for testability)

func NewClient

func NewClient(ctx context.Context, cfg config.RedisConfig) (*Client, error)

NewClient initializes and returns a new Redis client based on configuration.

func (*Client) Close added in v1.1.3

func (c *Client) Close() error

Close closes the Redis connection.

func (*Client) Get added in v1.1.3

func (c *Client) Get(ctx context.Context, key string) *redis.StringCmd

Get wraps the underlying Redis GET command and returns a *redis.StringCmd.

func (*Client) HealthStatus added in v1.1.1

func (c *Client) HealthStatus(ctx context.Context) string

HealthStatus returns a string describing the current health of the Redis connection.

func (*Client) IsConnected added in v1.1.1

func (c *Client) IsConnected(ctx context.Context) bool

IsConnected checks if the Redis client is connected and responsive.

func (*Client) SetEX added in v1.1.3

func (c *Client) SetEX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd

SetEX wraps the underlying Redis SETEX command (Set with EXPIRE).

type RedisCmdable added in v1.1.3

type RedisCmdable interface {
	Ping(ctx context.Context) *redis.StatusCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	SetEX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Close() error
}

RedisCmdable defines the subset of redis client methods we need. Keep it minimal so tests can provide simple mocks.

Jump to

Keyboard shortcuts

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