redis

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Flags = []cli.Flag{
	&cli.StringFlag{
		Name:    redisURL,
		Value:   "redis://localhost:6379/0",
		Usage:   "Redis connection URL",
		EnvVars: []string{"REDIS_URL"},
	},
}

Flags defines the CLI flags available for configuring the Redis connection. These flags enable the URL to be set via command-line arguments or environment variables.

Module provides the Redis client as an Fx module, enabling dependency injection for applications that require Redis as a data store.

Functions

func NewRedisClient

func NewRedisClient(cfg *Config) (*libredis.Client, error)

NewRedisClient initializes and returns a new Redis client instance configured with the provided Redis server URL from Config. This function parses the URL, creates a Redis client using the go-redis library, and ensures that the client can connect to the specified Redis server.

Parameters:

  • cfg (*Config): The configuration struct containing the Redis server URL.

Returns:

  • (*libredis.Client): The initialized Redis client instance.
  • (error): An error if URL parsing or client creation fails.

Types

type Config

type Config struct {
	URL string // The Redis connection URL
}

Config represents the configuration settings required to connect to the Redis server. It includes a single field, URL, which specifies the Redis connection URL.

func GetRedisConfig

func GetRedisConfig(c *cli.Context) *Config

GetRedisConfig reads the Redis URL from the CLI context, allowing configuration via command-line arguments or environment variables.

Parameters:

  • c (*cli.Context): The CLI context containing flag and environment variable values.

Returns:

  • (*Config): A Config struct populated with the Redis URL.

Jump to

Keyboard shortcuts

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