redis

package
v0.0.0-...-a5a6d41 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvHosts is returned when the provided host(s) is/are invalid
	ErrInvHosts = errors.New("Invalid hosts provided")
	// ErrPing is the error returned in case of ping failure
	ErrPing = errors.New("Ping failed")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Hosts           []string
	DB              int
	Password        string
	MaxRetries      int
	MinRetryBackoff time.Duration
	MaxRetryBackoff time.Duration

	DialTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration

	PoolSize           int
	PoolTimeout        time.Duration
	IdleTimeout        time.Duration
	IdleCheckFrequency time.Duration
}

Config struct has all the configurations required for redis

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler struct does all the cache operations

func New

func New(c Config) (*Handler, error)

New returns a handler instance with all the required attributes initialized

func (*Handler) Get

func (h *Handler) Get(key string, result interface{}) error

Get loads the value of the given key, from Redis to result

func (*Handler) Ping

func (h *Handler) Ping() error

Ping pings the redis server

func (*Handler) Set

func (h *Handler) Set(key string, value interface{}, expiry time.Duration) error

Set saves a new value in Redis with the given key, value and expiry

Jump to

Keyboard shortcuts

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