redis

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	NilClientError = errors.New("redis client cannot be nil")
	NilConfigError = 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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