rtools

package
v0.0.0-...-fea0222 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

rtools provide useful utilities for redis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(interface{}, error)

Callback function to receive results.

type Pipeline

type Pipeline struct {
	// contains filtered or unexported fields
}

Pipeline wraps a redis.Conn to provide pipelining. It can be used by concurrent callers, so it may be a good idea to use it instead of a connection pool for non-blocking commands.

func NewPipeline

func NewPipeline(conn redis.Conn) *Pipeline

Create a new pipeline.

func (*Pipeline) Close

func (p *Pipeline) Close() error

Closes the connection and releases all resources. Previously registered callbacks will eventually be called.

func (*Pipeline) Do

func (p *Pipeline) Do(callback Callback, cmdName string, args ...interface{})

Perform a command. Errors are deferred until a call to Flush(). Note that while callbacks will be invoked in order, they may be called in a separate goroutine than the one calling `Do()`.

func (*Pipeline) Flush

func (p *Pipeline) Flush(ctx context.Context) error

Flushes all previous commands and waits for them to finish. If the error is nil, all previous commands will be performed and the callback will be invoked with either the result or a Redis error.

Jump to

Keyboard shortcuts

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