-
Notifications
You must be signed in to change notification settings - Fork 701
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
support redis master-slave and fragmented redis switching functions #65
Comments
这个可以规定,redis cluster和普通redis实现了一个redis interface。 然后你通过运行环境,在代码层面将不同的redis实例赋值给定义为interface的Redis Stub,如下所示 var RedisStub RedisInterface
if env =="prod" {
RedisStub = redis.StdRedisClusterConfig("myredis").Build()
}else {
RedisStub = redis.StdRedisConfig("myredis").Build()
}
type RedisInterface interface {
Get()
Set()
...
} 我们会看一下,普通redis和redis cluster的方法有没有统一起来。你也可以按我们方法,先自己试一下。 |
ok |
Hi, 有人认领了这个Issue, 如果没有 我想Pick~ |
|
@askuy PTAL |
unified stub and cluster configuration #65
unified stub and cluster configuration douyu#65
使用场景:
在本地使用的单个Redis:
redisStub := redis.StdRedisConfig("myredis").Build()
在正式环境使用的是Redis集群:
redisStub := redis.StdRedisClusterConfig("myredis").Build()
这样就产生一个问题,在代码里使用Redis的地方都需要判断是本地环境还是线上正式环境。
在框架中是否可以进一步封装,对于使用者不用管是什么环境,只需要传一个参数来确定是否为Redis集群?或者有更好的方案?
The text was updated successfully, but these errors were encountered: