iface

package
v0.0.0-...-6d5e5c6 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Close will close all open connections to the remote Redis server.
	Close()

	// ReadReplica returns a host that points to the set of configured
	// read replicas. If no read replicas are configured, this returns
	// the current client. The client returned from this method does NOT
	// need to be independently closed (closing the source client will
	// also close replica clients).
	ReadReplica() Client

	// Do runs the command on the remote Redis server and returns its raw
	// response.
	Do(command string, args ...interface{}) (interface{}, error)

	// Pipeline returns a builder object to which commands can be attached.
	// All commands in the pipeline are sent to the remote server in a
	// single request and all results will be returned in a single response.
	// The MULTI/EXEC commands are added implicitly by the client. A pipeline
	// does NOT guarantee atomicity. If you require multiple commands to be
	// run atomically, bundle them in a Lua script and run it on the remote
	// server with the EVAL command.
	Pipeline() Pipeline
}

Client is a goroutine-safe, minimal, and pooled Redis client.

type Conn

type Conn interface {
	// Close the connection to the remote Redis server.
	Close() error

	// Do performs a command on the remote Redis server and returns
	// its result.
	Do(command string, args ...interface{}) (interface{}, error)

	// Send will publish command as part of a MULTI/EXEC sequence
	// to the remote Redis server.
	Send(command string, args ...interface{}) error
}

Conn abstracts a single, feature-minimal connection to Redis.

type Logger

type Logger interface {
	// Printf logs a message. Arguments should be handled in the manner of fmt.Printf.
	Printf(format string, args ...interface{})
}

Logger is an interface to the logger the client writes to.

type Pipeline

type Pipeline interface {
	// Add will attach a command to this pipeline. This command is
	// not sent to the remote server until Run is invoked.
	Add(command string, args ...interface{})

	// Run will send all commands attached to this pipeline in a
	// single request and return a slice of the results of each
	// command.
	Run() (interface{}, error)
}

Pipeline wraps an ordered sequence of commands to be processed with a single request/response exchange. This reduces bandwidth and latency around communication with the remote server.

type Pool

type Pool interface {
	// Close will drain all available connections from the pool.
	// Every live connection is closed. This method blocks.
	Close()

	// Borrow will block until a connection value is available in
	// the pool. If the connection is nil, then a new connection
	// is dialed in its place.
	Borrow() (Conn, bool)

	// BorrowTimeout is like borrow, but will return the pair
	// (nil, false) if no value is returned to the pool before the
	// given timeout elapses.
	BorrowTimeout(timeout time.Duration) (Conn, bool)

	// Release returns a connection to the pool. This method must
	// be called exactly once for each call to a Borrow method. A
	// connection which encountered an error should be returned to
	// the pool as a nil value.
	Release(conn Conn)
}

Pool abstracts a fixed-size Redis connection pool.

Jump to

Keyboard shortcuts

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