go.redis: github.com/daaku/go.redis Index | Files | Directories

package redis

import "github.com/daaku/go.redis"

Package redis implements a client for Redis.


Package Files

client.go connection.go flag.go format.go parse.go reply.go


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

type Client

type Client struct {
    Addr     string        // Server Address like "" 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:


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("", "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)


bufinpackage bufin implements a partially static buffed input reader.
bytecachePackage bytecache provides a redis backed bytecache.
bytestorePackage bytestore provides a redis backed bytestore.
redistestPackage redistest provides test redis server support.

Package redis imports 10 packages (graph) and is imported by 3 packages. Updated 2015-02-24. Refresh now. Tools for package owners.