Documentation ¶
Overview ¶
Package goredis is a library wrapped on top of github.com/go-redis/redis.
Index ¶
- Constants
- func Init(dsn string, opts ...Option) (*redis.Client, error)
- func InitCluster(addrs []string, username string, password string, opts ...Option) (*redis.ClusterClient, error)
- func InitSentinel(masterName string, addrs []string, username string, password string, ...) (*redis.Client, error)
- func InitSingle(addr string, password string, db int, opts ...Option) (*redis.Client, error)
- type Option
- func WithClusterOptions(opt *redis.ClusterOptions) Option
- func WithDialTimeout(t time.Duration) Option
- func WithEnableTrace() Option
- func WithReadTimeout(t time.Duration) Option
- func WithSentinelOptions(opt *redis.FailoverOptions) Option
- func WithSingleOptions(opt *redis.Options) Option
- func WithTLSConfig(c *tls.Config) Option
- func WithTracing(tp *trace.TracerProvider) Option
- func WithWriteTimeout(t time.Duration) Option
Constants ¶
const ( // ErrRedisNotFound not exist in redis ErrRedisNotFound = redis.Nil // DefaultRedisName default redis name DefaultRedisName = "default" )
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init connecting to redis dsn supported formats. (1) no password, no db: localhost:6379 (2) with password and db: <user>:<pass>@localhost:6379/2 (3) redis://default:123456@localhost:6379/0?max_retries=3 for more parameters see the redis source code for the setupConnParams function
func InitCluster ¶
func InitCluster(addrs []string, username string, password string, opts ...Option) (*redis.ClusterClient, error)
InitCluster connecting to redis for cluster, all redis username and password are the same
Types ¶
type Option ¶
type Option func(*options)
Option set the redis options.
func WithClusterOptions ¶ added in v1.0.9
func WithClusterOptions(opt *redis.ClusterOptions) Option
WithClusterOptions set redis cluster options
func WithDialTimeout ¶
WithDialTimeout set dail timeout
func WithEnableTrace ¶
func WithEnableTrace() Option
WithEnableTrace use trace, redis v8 Deprecated: use WithEnableTracer instead
func WithReadTimeout ¶
WithReadTimeout set read timeout
func WithSentinelOptions ¶ added in v1.0.9
func WithSentinelOptions(opt *redis.FailoverOptions) Option
WithSentinelOptions set redis sentinel options
func WithSingleOptions ¶ added in v1.0.9
func WithSingleOptions(opt *redis.Options) Option
WithSingleOptions set single redis options
func WithTracing ¶ added in v1.0.9
func WithTracing(tp *trace.TracerProvider) Option
WithTracing set redis tracer provider, redis v9
func WithWriteTimeout ¶
WithWriteTimeout set write timeout