rediscli

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteReadPipeline added in v1.7.1

func ExecuteReadPipeline(ctx context.Context, fn PipelineFunc) ([]redis.Cmder, error)

ExecuteReadPipeline executes multiple Redis read commands in a pipeline to reduce network round trips. It takes a context and a function that defines the commands to execute. The function should add commands to the pipeline but not execute them. Returns the command results and any error that occurred.

func ExecuteWritePipeline added in v1.7.1

func ExecuteWritePipeline(ctx context.Context, fn PipelineFunc) ([]redis.Cmder, error)

ExecuteWritePipeline executes multiple Redis write commands in a pipeline to reduce network round trips. It takes a context and a function that defines the commands to execute. The function should add commands to the pipeline but not execute them. Returns the command results and any error that occurred.

func RedisTLSOptions added in v1.3.2

func RedisTLSOptions(tlsCfg *config.TLS) *tls.Config

RedisTLSOptions checks if Redis TLS is enabled in the configuration. If TLS is enabled, it loads the X509 key pair and creates a tls.Config object. The loaded certificate is added to the tls.Config object. If an error occurs while loading the key pair, it logs the error and returns nil. If Redis TLS is disabled, it returns nil.

func UpdateRedisServerMetrics added in v1.7.3

func UpdateRedisServerMetrics(ctx context.Context)

UpdateRedisServerMetrics periodically collects and updates Redis server metrics

Types

type Client added in v1.4.10

type Client interface {
	// GetWriteHandle retrieves the Redis client's write handle for operations requiring write access.
	GetWriteHandle() redis.UniversalClient

	// GetReadHandle retrieves a Redis client's read handle, supporting multiple read handles for load balancing.
	GetReadHandle() redis.UniversalClient

	// GetWritePipeline returns a Redis pipeline for batching write operations.
	GetWritePipeline() redis.Pipeliner

	// GetReadPipeline returns a Redis pipeline for batching read operations.
	GetReadPipeline() redis.Pipeliner

	// Close releases all resources associated with the client, including write and read handles, and closes any open connections.
	Close()
}

Client defines an interface for interacting with a Redis client with methods for initialization and handle retrieval.

func GetClient added in v1.4.10

func GetClient() Client

func NewClient added in v1.4.10

func NewClient() Client

NewClient creates and returns a new instance of a Redis client that implements the Client interface.

func NewTestClient added in v1.4.10

func NewTestClient(db *redis.Client) Client

NewTestClient initializes and returns a new testClient instance, implementing the Client interface using the provided Redis client.

type PipelineFunc added in v1.7.1

type PipelineFunc func(pipe redis.Pipeliner) error

PipelineFunc is a function that executes Redis commands on a pipeline.

Jump to

Keyboard shortcuts

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