redis

package
v0.0.0-...-5650998 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2014 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdType

type CmdType byte

CmdType represents a type of command, it may be a send or a do.

const (
	// CmdSend represents a send call in redigo.
	CmdSend CmdType = iota
	// CmdDo represents a do call in redigo.
	CmdDo
)

type FailingFakeRedisConn

type FailingFakeRedisConn struct {
	FakeRedisConn
}

FailingFakeRedisConn is a fake connection that fails to execute commands (via Do and/or Send).

func (*FailingFakeRedisConn) Do

func (c *FailingFakeRedisConn) Do(cmd string, args ...interface{}) (interface{}, error)

func (*FailingFakeRedisConn) Send

func (c *FailingFakeRedisConn) Send(cmd string, args ...interface{}) error

type FakeRedisConn

type FakeRedisConn struct {
	Cmds []RedisCommand
	// contains filtered or unexported fields
}

FakeRedisConn is a fake implementation of redis.Conn.

It's useful for mocks only. You may use it with a pool:

fakePool := redis.NewPool(func() (redis.Conn, error) {
    return &FakeRedisConn{}, nil
}, 10)
conn := fakePool.Get()

func (*FakeRedisConn) Close

func (c *FakeRedisConn) Close() error

Close closes the connection.

func (*FakeRedisConn) Do

func (c *FakeRedisConn) Do(cmd string, args ...interface{}) (interface{}, error)

Do executes a do command, storing the arguments in the internal slice of commands. It doesn't return anything.

func (*FakeRedisConn) Err

func (c *FakeRedisConn) Err() error

Err returns the last error.

func (*FakeRedisConn) Flush

func (*FakeRedisConn) Flush() error

Flush does not do anything in the fake connection.

func (*FakeRedisConn) GetCommands

func (c *FakeRedisConn) GetCommands(tp CmdType) []RedisCommand

GetCommands return the list of commands of the given type.

func (*FakeRedisConn) Receive

func (*FakeRedisConn) Receive() (interface{}, error)

Receive does not do anything in the fake connection.

func (*FakeRedisConn) Send

func (c *FakeRedisConn) Send(cmd string, args ...interface{}) error

Send executes a send command, storing the arguments in the internal slice of commands. It doesn't return anything.

type RedisCommand

type RedisCommand struct {
	Cmd  string
	Args []interface{}
	Type CmdType
}

RedisCommand is a command sent to the redis server.

type ResultCommandRedisConn

type ResultCommandRedisConn struct {
	*FakeRedisConn
	Reply        map[string]interface{}
	DefaultReply interface{}
}

ResultCommandRedisConn is a fake connection that returns a result in the Do command.

func (*ResultCommandRedisConn) Do

func (c *ResultCommandRedisConn) Do(cmd string, args ...interface{}) (interface{}, error)

Do returns the result for a command as specified by the Reply map. If no command is provided, it will return DefaultReply.

Jump to

Keyboard shortcuts

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