redis

package module
v0.0.0-...-797e8bf Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2016 License: BSD-3-Clause Imports: 10 Imported by: 0

README

Documentation

Overview

Package redis implements a client for Redis.

Index

Constants

This section is empty.

Variables

View Source
var ErrProtocol = errors.New("go.redis: protocol error")

Functions

This section is empty.

Types

type Client

type Client struct {
	Addr     string        // Server Address like "127.0.0.1:6379" or "/run/redis.sock"
	Proto    string        // Server Protocol like "tcp" or "unix"
	PoolSize uint          // Connection Pool Size, must be specified
	Timeout  time.Duration // Timeout per call
	Stats    Stats         // For Stats collection
	// contains filtered or unexported fields
}

Client implements a Redis connection which is what you should typically use instead of the lower level Conn interface. It implements a fixed size connection pool and supports per-call timeout.

func ClientFlag

func ClientFlag(name string) *Client

Define a Client via flag parameters. For example if name is "redis", it will provide:

-redis.proto=unix
-redis.addr=/run/redis.sock
-redis.pool-size=10
-redis.timeout=1s

func (*Client) Call

func (c *Client) Call(args ...interface{}) (reply *Reply, err error)

Call is the canonical way of talking to Redis. It accepts any Redis command and a arbitrary number of arguments.

type Conn

type Conn interface {
	// Write accepts any redis command and arbitrary list of arguments.
	//
	//     Write("SET", "counter", 1)
	//     Write("INCR", "counter")
	//
	// Write might return a net.Conn.Write error
	Write(args ...interface{}) error

	// Read a single reply from the connection. If there is no reply waiting
	// this method will block.
	Read() (*Reply, error)

	// Close the Connection.
	Close() error

	// Returns the underlying net.Conn. This is useful for example to set
	// set a r/w deadline on the connection.
	//
	//      conn.Sock().SetDeadline(t)
	Sock() net.Conn
}

Represents a Connection to the server and abstracts the read/write via a connection.

func Dial

func Dial(addr, proto string, timeout time.Duration) (Conn, error)

Dial expects a network address, protocol and a dial timeout:

Dial("127.0.0.1:6379", "tcp", time.Second)

Or for a unix domain socket:

Dial("/path/to/redis.sock", "unix", time.Second)

type Elem

type Elem []byte

func (Elem) Bool

func (e Elem) Bool() bool

func (Elem) Bytes

func (e Elem) Bytes() []byte

func (Elem) Float64

func (e Elem) Float64() float64

func (Elem) Int

func (e Elem) Int() int

func (Elem) Int64

func (e Elem) Int64() int64

func (Elem) String

func (e Elem) String() string

type Message

type Message struct {
	Channel string
	Elem    Elem
}

type Reply

type Reply struct {
	Err   error
	Elem  Elem
	Elems []*Reply
}

func (*Reply) BytesArray

func (r *Reply) BytesArray() [][]byte

func (*Reply) Hash

func (r *Reply) Hash() map[string]Elem

func (*Reply) IntArray

func (r *Reply) IntArray() []int64

func (*Reply) Len

func (r *Reply) Len() int

func (*Reply) Message

func (r *Reply) Message() *Message

func (*Reply) Nil

func (r *Reply) Nil() bool

func (*Reply) StringArray

func (r *Reply) StringArray() []string

func (*Reply) StringMap

func (r *Reply) StringMap() map[string]string

type Stats

type Stats interface {
	Inc(name string)
	Record(name string, value float64)
}

Directories

Path Synopsis
package bufin implements a partially static buffed input reader.
package bufin implements a partially static buffed input reader.
Package bytecache provides a redis backed bytecache.
Package bytecache provides a redis backed bytecache.
Package bytestore provides a redis backed bytestore.
Package bytestore provides a redis backed bytestore.
Package redistest provides test redis server support.
Package redistest provides test redis server support.

Jump to

Keyboard shortcuts

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