Documentation
¶
Index ¶
- func ExecuteReadPipeline(ctx context.Context, fn PipelineFunc) ([]redis.Cmder, error)
- func ExecuteWritePipeline(ctx context.Context, fn PipelineFunc) ([]redis.Cmder, error)
- func RedisTLSOptions(tlsCfg *config.TLS) *tls.Config
- func UpdateRedisServerMetrics(ctx context.Context)
- type Client
- type PipelineFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteReadPipeline ¶ added in v1.7.1
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
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
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
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 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
NewTestClient initializes and returns a new testClient instance, implementing the Client interface using the provided Redis client.
type PipelineFunc ¶ added in v1.7.1
PipelineFunc is a function that executes Redis commands on a pipeline.