Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

we may don't need to make sure redis connection is alive in our code #90

Open
MayyS opened this issue May 18, 2024 · 0 comments
Open

we may don't need to make sure redis connection is alive in our code #90

MayyS opened this issue May 18, 2024 · 0 comments

Comments

@MayyS
Copy link

MayyS commented May 18, 2024

I have a question about this code snippet. Do we need to implement our own connection keep-alive mechanism in the code?

again:
for {
select {
case <-ctx.Done():
return
case <-tick.C:
if !shouldConnect() {
continue
}
for _, v := range c {
if !connectSingleton(v.IsCache, config) {
redisUp.Store(false)
goto again
}
if !clusterConnectionIsOpen(v) {
redisUp.Store(false)
goto again
}
}
redisUp.Store(true)
}
}
}

I noticed a code snippet in the go-redis library that seems to handle connection keep-alive for us.
https://github.com/redis/go-redis/blob/2eb36ad9c874df5d87c320a816a3687286d10786/internal/pool/pool.go#L87-L106
So, I think that we don't need to implement connection keep-alive in our code again. Is my understanding correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant