redis / rueidis

A fast Golang Redis client that supports Client Side Caching, Auto Pipelining, Generics OM, RedisJSON, RedisBloom, RediSearch, etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to set so_reuseaddr for rueidis?

ouvaa opened this issue · comments

i have multiple rueidis instances clients running per process and connects to multiple redis server backend.

i would like to minimize the ports generated as a redis proxy e.g.:
https://blog.cloudflare.com/how-to-stop-running-out-of-ephemeral-ports-and-start-to-love-long-lived-connections

how to do so_reuseaddr for rueidis with plenty of ruedis client processes running concurrently?

Hi @ouvaa,

You can do it in the DialFn function:

rueidis.NewClient(rueidis.ClientOption{
	DialFn: func(s string, dialer *net.Dialer, config *tls.Config) (conn net.Conn, err error) {
		// return your so_reuseaddr enabled net.Conn here
	},
})

thx

thx