Documentation ¶
Index ¶
- type CmdType
- type FailingFakeRedisConn
- type FakeRedisConn
- func (c *FakeRedisConn) Close() error
- func (c *FakeRedisConn) Do(cmd string, args ...interface{}) (interface{}, error)
- func (c *FakeRedisConn) Err() error
- func (*FakeRedisConn) Flush() error
- func (c *FakeRedisConn) GetCommands(tp CmdType) []RedisCommand
- func (*FakeRedisConn) Receive() (interface{}, error)
- func (c *FakeRedisConn) Send(cmd string, args ...interface{}) error
- type RedisCommand
- type ResultCommandRedisConn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) 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) 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 ¶
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.