We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
貌似现在只支持一个redis实例(default),希望能支持多个。
The text was updated successfully, but these errors were encountered:
目前是支持的,以增加 user-service 为例, 添加步骤如下:
user-service
1、增加多实例配置
default: Addr: 127.0.0.1:6379 Password: "" DB: 0 MinIdleConn: 200 DialTimeout: 60s ReadTimeout: 500ms WriteTimeout: 500ms PoolSize: 100 PoolTimeout: 240s EnableTrace: true user-service: Addr: 127.0.0.1:6379 Password: "" DB: 0 MinIdleConn: 200 DialTimeout: 60s ReadTimeout: 500ms WriteTimeout: 500ms PoolSize: 100 PoolTimeout: 240s EnableTrace: true
2、实例化多个redis
internal/cache下的 redis.Init 只实例化默认redis实例,如果需要开启多实例请参考下面写法
redis.Init
package cache import ( "github.com/go-eagle/eagle/pkg/redis" "github.com/google/wire" rdb "github.com/redis/go-redis/v9" ) // 新增 var ( // 全局实例 UserRedis *rdb.Client ) // ProviderSet is cache providers. var ProviderSet = wire.NewSet(redis.Init, NewUserCache) // 新增 func init() { mgr := redis.NewRedisManager() // user-service 对应到配置里的新增的 section // 绑定到对应的全局变量上 UserRedis, err := mgr.GetClient("user-service") if err != nil { panic(err) } _ = UserRedis }
3、最后就可以在对应的地方进行使用了
希望可以帮到你 😄
Sorry, something went wrong.
收到,感谢!
No branches or pull requests
貌似现在只支持一个redis实例(default),希望能支持多个。
The text was updated successfully, but these errors were encountered: