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.

Index

Package Files

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

Variables

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

type Client Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

type Elem []byte

func (Elem) Bool Uses

func (e Elem) Bool() bool

func (Elem) Bytes Uses

func (e Elem) Bytes() []byte

func (Elem) Float64 Uses

func (e Elem) Float64() float64

func (Elem) Int Uses

func (e Elem) Int() int

func (Elem) Int64 Uses

func (e Elem) Int64() int64

func (Elem) String Uses

func (e Elem) String() string

type Message Uses

type Message struct {
    Channel string
    Elem    Elem
}

type Reply Uses

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

func (*Reply) BytesArray Uses

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

func (*Reply) Hash Uses

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

func (*Reply) IntArray Uses

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

func (*Reply) Len Uses

func (r *Reply) Len() int

func (*Reply) Message Uses

func (r *Reply) Message() *Message

func (*Reply) Nil Uses

func (r *Reply) Nil() bool

func (*Reply) StringArray Uses

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

func (*Reply) StringMap Uses

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

type Stats Uses

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

Directories

PathSynopsis
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 2016-07-19. Refresh now. Tools for package owners.