redis

package
v1.2.10 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStopLoop = errors.New("stop")

Functions

func ForeachSet

func ForeachSet(ctx context.Context, c *redis.Client, key string, cursor uint64, pageSize int64, f func(key, val string) error) (err error)

func NewRedisClient

func NewRedisClient(ctx context.Context, option *Options) (*redis.Client, error)

Types

type Client

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

func (Client) MarshalJSON

func (r Client) MarshalJSON() ([]byte, error)

func (Client) MarshalJSONPB added in v1.2.8

func (r Client) MarshalJSONPB(_ *jsonpb.Marshaler) ([]byte, error)

func (*Client) Redis

func (r *Client) Redis(ctx context.Context) *redis.Client

func (*Client) UnmarshalJSON

func (r *Client) UnmarshalJSON(data []byte) (err error)

type Cmder

type Cmder struct {
	redis.Cmder
}

func (Cmder) String

func (c Cmder) String() string

type Options added in v1.2.0

type Options struct {
	URL      string      `json:"url,omitempty"`
	Password safe.String `json:"password"`
	// Database to be selected after connecting to the server.
	DB *int `json:"db"`

	// Maximum number of retries before giving up.
	// Default is to not retry failed commands.
	MaxRetries *int `json:"max_retries"`
	// Minimum backoff between each retry.
	// Default is 8 milliseconds; -1 disables backoff.
	MinRetryBackoff *model.Duration `json:"min_retry_backoff"`
	// Maximum backoff between each retry.
	// Default is 512 milliseconds; -1 disables backoff.
	MaxRetryBackoff *model.Duration `json:"max_retry_backoff"`

	// Dial timeout for establishing new connections.
	// Default is 5 seconds.
	DialTimeout *model.Duration `json:"dial_timeout"`
	// Timeout for socket reads. If reached, commands will fail
	// with a timeout instead of blocking. Use value -1 for no timeout and 0 for default.
	// Default is 3 seconds.
	ReadTimeout *model.Duration `json:"read_timeout"`
	// Timeout for socket writes. If reached, commands will fail
	// with a timeout instead of blocking.
	// Default is ReadTimeout.
	WriteTimeout *model.Duration `json:"write_timeout"`

	// Maximum number of socket connections.
	// Default is 10 connections per every CPU as reported by runtime.NumCPU.
	PoolSize *int `json:"pool_size"`
	// Minimum number of idle connections which is useful when establishing
	// new connection is slow.
	MinIdleConns *int `json:"min_idle_conns"`
	// Connection age at which client retires (closes) the connection.
	// Default is to not close aged connections.
	MaxConnAge *time.Duration `json:"max_conn_age"`
	// Amount of time client waits for connection if all connections
	// are busy before returning an error.
	// Default is ReadTimeout + 1 second.
	PoolTimeout *time.Duration `json:"pool_timeout"`
	// Amount of time after which client closes idle connections.
	// Should be less than server's timeout.
	// Default is 5 minutes. -1 disables idle timeout check.
	IdleTimeout *time.Duration `json:"idle_timeout"`
	// Frequency of idle checks made by idle connections reaper.
	// Default is 1 minute. -1 disables idle connections reaper,
	// but idle connections are still discarded by the client
	// if IdleTimeout is set.
	IdleCheckFrequency *time.Duration  `json:"idle_check_frequency"`
	TLSConfig          *tls.TLSOptions `json:"tls_config" yaml:"tls_config" mapstructure:"tls_config"`
	// contains filtered or unexported fields
}

func (*Options) GetPeer added in v1.2.0

func (o *Options) GetPeer() (string, int)

func (*Options) UnmarshalJSON added in v1.2.0

func (o *Options) UnmarshalJSON(data []byte) (err error)

type Session

type Session struct {
	*redis.Client
}

Jump to

Keyboard shortcuts

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