Closed nicolasassi closed 3 years ago
in addition to that, I'm able to connect normaly to redis when running my application out of docker connecting to redis inside the container. The problem only occurs when trying to connect when both sides are in containers
any idea about that? i met the same problem...
@bamstars ended up using redis instead of cache as I could not solve this problem...
@nicolasassi thank you for you kindly reply, i found this problem when deployed server app in a docker whatever deployed redis instance in either docker or local host. My current solution is using UniversalClient instead of Ring, it seems work well so far, code like below
// ring := redis.NewRing(&redis.RingOptions{ // Addrs: conf.AddrPort, // Password: conf.Password, // DB: conf.DB, // })
rdb := redis.NewUniversalClient(&redis.UniversalOptions{
Addrs: conf.AddrPort,
Password: conf.Password,
DB: conf.DB,
})
return cache.New(&cache.Options{
Redis: rdb,
LocalCache: cache.NewTinyLFU(
conf.Size,
time.Duration(conf.TtlInHours)*time.Hour),
})
Detail docs about UniversalClient and Cache can be found here https://redis.uptrace.dev/guide/universal.html https://redis.uptrace.dev/guide/caching.html
I'm having problems regarding connecting to redis on docker as seems in the title.
My go code stands as follows:
my docker-compose responsible for redis:
My docker-compose for the go service: