redis

package
v0.0.0-...-e1e9d1d Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package redis defines the standard interface for a redis database. It aims for a small api surface, and given the extensibility capabilies of redis, allows for arbitrary commands to be executed. As such, it is closer to the redigo Go package's interface, other client packages may require an adapter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	// Close releases the resources used by the connection.
	Close() error

	// Do executes an arbitrary command with the provided arguments.
	Do(ctx context.Context, commandName string, args ...interface{}) (reply interface{}, err error)

	// Send queues a command to be executed, but does not execute the roundtrip
	// yet. A subsequent call to Do (either with the last command
	// in the pipeline or with an empty command) executes the pipeline.
	Send(ctx context.Context, commandName string, args ...interface{}) error
}

Conn defines the methods required for a Redis connection.

type MockConn

type MockConn struct {
	CloseFunc func() error
	DoFunc    func(context.Context, string, ...interface{}) (interface{}, error)
	SendFunc  func(context.Context, string, ...interface{}) error
}

MockConn is a test mock for the Conn interface.

func (*MockConn) Close

func (m *MockConn) Close() error

func (*MockConn) Do

func (m *MockConn) Do(ctx context.Context, cmd string, args ...interface{}) (interface{}, error)

func (*MockConn) Send

func (m *MockConn) Send(ctx context.Context, cmd string, args ...interface{}) error

type MockPool

type MockPool struct {
	GetFunc   func(context.Context) Conn
	CloseFunc func() error
}

MockPool is a test mock for the Pool interface.

func (*MockPool) Close

func (m *MockPool) Close() error

func (*MockPool) Get

func (m *MockPool) Get(ctx context.Context) Conn

type Pool

type Pool interface {
	// Get returns a connection from the pool. The context is applied to the
	// connection attempt by the pool. Any expiration on the context will not
	// affect the returned connection - the connection itself should be managed
	// via timeouts.
	Get(ctx context.Context) Conn

	// Close closes the pool and any resources associated with it.
	Close() error
}

Pool defines the methods required for a Redis pool.

Jump to

Keyboard shortcuts

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