redis

package
v0.0.0-...-a89d410 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 30 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 struct {
	// contains filtered or unexported fields
}

func (*Client) CmdOnMaster

func (ins *Client) CmdOnMaster() *redis.Client

func (*Client) CmdOnSlave

func (ins *Client) CmdOnSlave() *redis.Client

type ClusterClient

type ClusterClient struct {
	redis.ClusterClient
}

type ClusterOptions

type ClusterOptions struct {
	Config
}

ClusterOptions 集群配置信息

func ClusterConfig

func ClusterConfig(name string) *ClusterOptions

ClusterConfig 集群模式

func DefaultClusterOption

func DefaultClusterOption() *ClusterOptions

DefaultClusterOption default option ...

func RawClusterConfig

func RawClusterConfig(key string) *ClusterOptions

func (*ClusterOptions) BuildCluster

func (config *ClusterOptions) BuildCluster() (*ClusterClient, error)

BuildCluster ..

func (*ClusterOptions) ClusterSingleton

func (config *ClusterOptions) ClusterSingleton() (*ClusterClient, error)

ClusterSingleton returns a singleton client conn.

func (*ClusterOptions) MustClusterBuild

func (config *ClusterOptions) MustClusterBuild() *ClusterClient

MustClusterBuild panics when error found.

func (*ClusterOptions) MustClusterSingleton

func (config *ClusterOptions) MustClusterSingleton() *ClusterClient

MustClusterSingleton panics when error found.

type Config

type Config struct {
	// Master host:port addresses of Master node
	Master struct {
		Addr string `json:"addr" toml:"addr"`
	} `json:"master" toml:"master"`
	// Slaves A list of host:port addresses of Slave nodes.
	Slaves struct {
		Addr []string `json:"addr" toml:"addr"`
	} `json:"slaves" toml:"slaves"`

	Addr     []string `json:"addr" toml:"addr"`
	Username string   `json:"username" toml:"username"`
	Password string   `json:"password" toml:"password"`

	/****** for github.com/go-redis/redis/v8 ******/
	// DB default 0,not recommend
	DB int `json:"db" toml:"db"`
	// PoolSize applies per Stub node and not for the whole Stub.
	PoolSize int `json:"poolSize" toml:"poolSize"`
	// Maximum number of retries before giving up.
	// Default is 3 retries; -1 (not 0) disables retries.
	MaxRetries int `json:"maxRetries" toml:"maxRetries"`
	// Minimum number of idle connections which is useful when establishing
	// new connection is slow.
	MinIdleConns int `json:"minIdleConns" toml:"minIdleConns"`
	// Dial timeout for establishing new connections.
	// Default is 5 seconds.
	DialTimeout time.Duration `json:"dialTimeout" toml:"dialTimeout"`
	// Timeout for socket reads. If reached, commands will fail
	// with a timeout instead of blocking. Use value 0 for no timeout and 0 for default.
	// Default is 3 seconds.
	ReadTimeout time.Duration `json:"readTimeout" toml:"readTimeout"`
	// Timeout for socket writes. If reached, commands will fail
	// with a timeout instead of blocking.
	// Default is ReadTimeout.
	WriteTimeout time.Duration `json:"writeTimeout" toml:"writeTimeout"`
	// 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:"idleTimeout" toml:"idleTimeout"`

	/****** for sanchin ******/
	ReadOnMaster bool `json:"readOnMaster" toml:"readOnMaster"`
	// nice option
	Debug bool `json:"debug" toml:"debug"`
	// a require will be recorded if cost bigger than this
	SlowLogThreshold time.Duration `json:"slowThreshold" toml:"slowThreshold"`
	// EnableMetric .. default true
	EnableMetricInterceptor bool `json:"enableMetric" toml:"enableMetric"`
	// EnableTrace .. default true
	EnableTraceInterceptor bool `json:"enableTrace" toml:"enableTrace"`
	// EnableAccessLog .. default false
	EnableAccessLogInterceptor bool `json:"enableAccessLog" toml:"enableAccessLog"`
	// EnableSentinel .. default true
	EnableSentinel bool `json:"enableSentinel" toml:"enableSentinel"`
	// OnDialError panic|error
	OnDialError string `json:"level"`
	// contains filtered or unexported fields
}

Config ...

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig default config ...

func RawConfig

func RawConfig(key string) *Config

func StdConfig

func StdConfig(name string) *Config

StdConfig 哨兵模式,支持主从结构redis集群

func (*Config) Build

func (config *Config) Build() (*Client, error)

Build ..

func (*Config) MustBuild

func (config *Config) MustBuild() *Client

MustBuild panics when error found.

func (*Config) MustSingleton

func (config *Config) MustSingleton() *Client

MustSingleton panics when error found.

func (*Config) Singleton

func (config *Config) Singleton() (*Client, error)

Singleton returns a singleton client conn.

Jump to

Keyboard shortcuts

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