redis

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// KeySeparator is the separator for the Redis key
	KeySeparator = ":"
)

Variables

View Source
var (
	ErrNilClient = errors.New("redis client cannot be nil")
	ErrNilConfig = errors.New("redis config cannot be nil")
)

Functions

func GetKey

func GetKey(key string, prefixes ...string) string

GetKey returns a key with the given key prefixes

Types

type Config

type Config struct {
	Uri      string
	Password string
	Database int
}

Config struct

type ConnectionHandler

type ConnectionHandler interface {
	Connect() (*redis.Client, error)
	GetClient() (*redis.Client, error)
	Disconnect()
}

ConnectionHandler interface

type DefaultConnectionHandler

type DefaultConnectionHandler struct {
	Client        *redis.Client
	ClientOptions *redis.Options
}

DefaultConnectionHandler struct

func NewDefaultConnectionHandler

func NewDefaultConnectionHandler(config *Config) (
	*DefaultConnectionHandler,
	error,
)

NewDefaultConnectionHandler creates a new connection

func (*DefaultConnectionHandler) Connect

func (d *DefaultConnectionHandler) Connect() (*redis.Client, error)

Connect returns a new Redis client

func (*DefaultConnectionHandler) Disconnect

func (d *DefaultConnectionHandler) Disconnect()

Disconnect closes the Redis client connection

func (*DefaultConnectionHandler) GetClient

func (d *DefaultConnectionHandler) GetClient() (*redis.Client, error)

GetClient returns the Redis client

Jump to

Keyboard shortcuts

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