redis

package
v1.1.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginsRoot = root + ".plugins"
)

Variables

This section is empty.

Functions

func ConfigAdd

func ConfigAdd(path string)

func NewClient

func NewClient(ctx context.Context, plugins ...Plugin) (*redis.Client, error)

NewClient returns a new redis client.

func NewClientWithConfigPath

func NewClientWithConfigPath(ctx context.Context, path string, plugins ...Plugin) (*redis.Client, error)

NewClientWithConfigPath returns a new redis client with options from config path.

func NewClientWithOptions

func NewClientWithOptions(ctx context.Context, o *Options, plugins ...Plugin) (client *redis.Client, err error)

NewClientWithOptions returns a new redis client with options.

func NewClusterClient

func NewClusterClient(ctx context.Context, plugins ...ClusterPlugin) (*redis.ClusterClient, error)

NewClusterClient returns a new ClusterClient.

func NewClusterClientWithConfigPath

func NewClusterClientWithConfigPath(ctx context.Context, path string, plugins ...ClusterPlugin) (*redis.ClusterClient, error)

NewClusterClientWithConfigPath returns a new ClusterClient with options from config path.

func NewClusterClientWithOptions

func NewClusterClientWithOptions(ctx context.Context, o *Options, plugins ...ClusterPlugin) (client *redis.ClusterClient, err error)

NewClusterClientWithOptions returns a new ClusterClient with options.

Types

type ClientOptions

type ClientOptions struct {
	Addr    string
	Network string
	DB      int `config:"db"`
}

ClientOptions represents the redis client options.

type ClusterOptions

type ClusterOptions struct {
	Addrs          []string
	MaxRedirects   int
	ReadOnly       bool
	RouteByLatency bool
	RouteRandomly  bool
}

ClusterOptions represents a redis cluster client options.

type ClusterPlugin

type ClusterPlugin func(context.Context, *redis.ClusterClient) error

ClusterPlugin represents a redis cluster plugin func signature.

type ManagedClient

type ManagedClient struct {
	Client  *redis.Client
	Plugins []Plugin
	Options *Options
}

ManagedClient represents a redis managed client.

func NewManagedClient

func NewManagedClient(ctx context.Context, plugins ...Plugin) (*ManagedClient, error)

NewManagedClient returns a new managed client with default options.

func NewManagedClientWithConfigPath

func NewManagedClientWithConfigPath(ctx context.Context, path string, plugins ...Plugin) (*ManagedClient, error)

NewManagedClientWithConfigPath returns a new managed client with options from config path.

func NewManagedClientWithOptions

func NewManagedClientWithOptions(ctx context.Context, opts *Options, plugins ...Plugin) (*ManagedClient, error)

NewManagedClientWithOptions returns a new managed client with options.

type ManagedClusterClient

type ManagedClusterClient struct {
	Client  *redis.ClusterClient
	Plugins []ClusterPlugin
	Options *Options
}

ManagedClusterClient represents a redis cluster managed client.

func NewManagedClusterClient

func NewManagedClusterClient(ctx context.Context, plugins ...ClusterPlugin) (*ManagedClusterClient, error)

NewManagedClusterClient returns a new managed client with default options.

func NewManagedClusterClientWithConfigPath

func NewManagedClusterClientWithConfigPath(ctx context.Context, path string, plugins ...ClusterPlugin) (*ManagedClusterClient, error)

NewManagedClusterClientWithConfigPath returns a new managed client with options from config path.

func NewManagedClusterClientWithOptions

func NewManagedClusterClientWithOptions(ctx context.Context, opts *Options, plugins ...ClusterPlugin) (*ManagedClusterClient, error)

NewManagedClusterClientWithOptions returns a new managed client with options.

type Options

type Options struct {
	Sentinel           SentinelOptions
	Password           string
	MaxRetries         int
	MinRetryBackoff    time.Duration
	MaxRetryBackoff    time.Duration
	DialTimeout        time.Duration
	ReadTimeout        time.Duration
	WriteTimeout       time.Duration
	PoolSize           int
	MinIdleConns       int
	MaxConnAge         time.Duration
	PoolTimeout        time.Duration
	IdleTimeout        time.Duration
	IdleCheckFrequency time.Duration
	Client             ClientOptions
	Cluster            ClusterOptions
}

Options represents redis client set options.

func NewOptions

func NewOptions() (*Options, error)

NewOptions returns options from config file or environment vars.

func NewOptionsWithPath

func NewOptionsWithPath(path string) (opts *Options, err error)

NewOptionsWithPath unmarshals options based a given key path.

type Plugin

type Plugin func(context.Context, *redis.Client) error

Plugin defines a function to process plugin.

type SentinelOptions

type SentinelOptions struct {
	MasterName string
	Addrs      []string
	Password   string
}

SentinelOptions represents redis sentinel options.

Directories

Path Synopsis
examples
plugins

Jump to

Keyboard shortcuts

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