red

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRedisNetwork the redis network option, "tcp"
	DefaultRedisNetwork = "tcp"
	// DefaultRedisAddr the redis address option, "127.0.0.1:6379"
	DefaultRedisAddr = "127.0.0.1:6379"
	// DefaultRedisIdleTimeout the redis idle timeout option, time.Duration(5) * time.Minute
	DefaultRedisIdleTimeout = time.Duration(5) * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Network     string
	Addr        string
	Password    string
	Database    int
	MaxIdle     int
	MaxActive   int
	IdleTimeout time.Duration
}

Config the redis configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default redis configuration

func (Config) Merge

func (c Config) Merge(cfg Config) (config Config)

Merge merges the default with the given config and returns the result

type Redis

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

A Redis model

func New

func New(c Config) *Redis

New connects to the redis

func (*Redis) Del

func (r *Redis) Del(key string) (interface{}, error)

Del deletes by key

func (*Redis) Get

func (r *Redis) Get(key string) (interface{}, error)

Get returns value, err by its key

func (*Redis) GetString

func (r *Redis) GetString(key string) (string, error)

GetString returns value, err by its key

func (*Redis) HGetAll

func (r *Redis) HGetAll(key string) (interface{}, error)

HGetAll returns a reply by key

func (*Redis) HGetAllMap

func (r *Redis) HGetAllMap(key string) (map[string]string, error)

HGetAllMap returns a map[string]string by key

func (*Redis) HmSet

func (r *Redis) HmSet(key string, val map[string]string) (interface{}, error)

HmSet sets a map[string]string by key

func (*Redis) Ping

func (r *Redis) Ping() (bool, error)

Ping returns true if pong received otherwise false

Jump to

Keyboard shortcuts

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