package
1.12.6
Repository: https://github.com/go-dev-frame/sponge.git
Documentation: pkg.go.dev

# README

goredis

goredis library wrapped in go-redis.


Example of use

Single Redis

	// way 1: redis version 6.0 or above
	redisCli, err := goredis.Init("default:[email protected]:6379") // can set parameters such as timeout, tls, tracing, such as goredis.Withxxx()
	if err != nil {
		panic("goredis.Init error: " + err.Error())
	}

	// way 2: redis version 5.0 or below
	redisCli, err := goredis.InitSingle("127.0.0.1:6379", "123456", 0) // can set parameters such as timeout, tls, tracing, such as goredis.Withxxx()

Sentinel

	addrs := []string{"127.0.0.1:6380", "127.0.0.1:6381", "127.0.0.1:6382","127.0.0.1:26380", "127.0.0.1:26381", "127.0.0.1:26382"}
	rdbCli, err : := goredis.InitSentinel("mymaster", addrs, "", "123456") // can set parameters such as timeout, tls, tracing, such as goredis.Withxxx()

Cluster

	addrs := []string{"127.0.0.1:6380", "127.0.0.1:6381", "127.0.0.1:6382","127.0.0.1:6383", "127.0.0.1:6384", "127.0.0.1:6385"}
	clusterRdb, err : := goredis.InitCluster(addrs, "", "123456") // can set parameters such as timeout, tls, tracing, such as goredis.Withxxx()

Official Documents https://redis.uptrace.dev/zh/guide/go-redis.html

# Functions

Close redis client.
CloseCluster redis cluster client.
Init connecting to redis dsn supported formats.
InitCluster connecting to redis for cluster, all redis username and password are the same.
InitSentinel connecting to redis for sentinel, all redis username and password are the same.
InitSingle connecting to single redis instance.
WithClusterOptions set redis cluster options.
WithDialTimeout set dail timeout.
WithEnableTrace use trace, redis v8 Deprecated: use WithEnableTracer instead.
WithReadTimeout set read timeout.
WithSentinelOptions set redis sentinel options.
WithSingleOptions set single redis options.
WithTLSConfig set TLS config.
WithTracing set redis tracer provider, redis v9.
WithWriteTimeout set write timeout.

# Constants

DefaultRedisName default redis name.
ErrRedisNotFound not exist in redis.

# Type aliases

Client is a redis client.
Option set the redis options.