redis

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// INF for Infinity
	INF = "+inf"
)

Variables

View Source
var ConfigPrefix = "REDIS"

ConfigPrefix define configuration prefix

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option defines a Redis option

func Database

func Database(database int) Option

Database returns database option

func Host

func Host(host string) Option

Host returns host option

func KeyPrefix

func KeyPrefix(keyPrefix string) Option

KeyPrefix returns key prefix option

func Logger

func Logger(logger logger.Logger) Option

Logger returns logger option

func Password

func Password(password string) Option

Password returns password option

func PingDelay

func PingDelay(pingDelay time.Duration) Option

PingDelay returns ping delay option

func Port

func Port(port int) Option

Port returns port option

type Options

type Options struct {
	Logger logger.Logger `ignored:"true" json:"-"`

	Host     string `default:"0.0.0.0" envconfig:"HOST"`
	Port     int    `default:"6379" envconfig:"PORT"`
	Password string `default:"" envconfig:"PASSWORD"`
	Database int    `default:"0" envconfig:"DATABASE"`

	PingDelay time.Duration `default:"2s" envconfig:"PING_DELAY"`

	KeyPrefix string `default:"" envconfig:"KEY_PREFIX"`
}

Options represents Redis options

type Redis

type Redis interface {
	Connect()
	Disconnect() error

	Increment(string) (int64, error)
	Decrement(string) (int64, error)

	Set(string, string, time.Duration) error
	Get(string) (string, error)
	Del(string) (int64, error)
	Exists(string) (int64, error)

	SearchByKey(string) ([]string, error)

	SetMemberAdd(string, ...string) error
	SetMemberExists(string, string) (bool, error)
	SetMemberDelete(string, string) (int64, error)
	SetMembers(string) ([]string, error)
	SetLength(string) (int64, error)

	HashItemAdd(string, string, string) error
	HashItemExists(string, string) (bool, error)
	HashItemGet(string, string) (string, error)
	HashItemDelete(string, string) (int64, error)
	HashItems(string) (map[string]string, error)
	HashLength(string) (int64, error)

	ScoreItemAdd(string, float64, string) error
	ScoreItemCount(string, string, string) (float64, error)

	PubSubPublish(string, string) error
	PubSubSubscribe(string, chan<- string) error

	FlushAll() error
}

Redis represents the Redis interface

func New

func New(opts ...Option) (Redis, error)

New creates a new Redis instance

Jump to

Keyboard shortcuts

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