Closed yangyang880402 closed 3 years ago
It was added in https://github.com/yiisoft/yii2-redis/pull/178, commit is https://github.com/yiisoft/yii2-redis/pull/178/commits/c868cc6b8d256e0b5cc22a50923cc174f4b6e747. @hofrob should know for sure.
Hi,
This was a long time ago, but I'll try: The cluster will redirect you every single time you're doing something with redis and may redirect you to different servers every time. So as soon as you're done, the redirectConnectionString
has to be discarded. It's only used temporarily while performing something on the cluster. If you don't discard this value getConnectionString()
would return the same "redirect" connection every time.
As far as I remember one should always ask the master first before performing an action on the cluster.
Are you running these commands on a cluster? Which settings are you using in your cache config? See getIsCluster()
and forceClusterMode
.
This example is not really saying a lot to be honest. You're running \Yii::$app->redis->setex
and then $redis->get
. What is $redis
?
I have a scene, I need in one request operation redis for many times, if according to your description, I will need to connect redis service for many times. But I don't want to connect many times in the same request. It's performance is too low.
You will need to provide more info. As mentioned in my previous post.
To add to that: Connection are not closed and reopened. They're kept in a pool: https://github.com/yiisoft/yii2-redis/blob/ead6d1f1a99c171449e42fe0e00bfc3fcf3a27a6/src/Connection.php#L563
e.g. $redis = \Yii::$app->redis; $ret = $redis->get("token"); if(!$ret ){ $ret = $redis->setex("token", 100, "token123"); }
$ret = $redis->setex("key1"); ........ $ret = $redis->setex("key2"); ........ $ret = $redis->setex("key2");
To add to that: Connection are not closed and reopened. They're kept in a pool:
This seems to be invalid
As long as you don't answer the questions above, post your config, tell us your setup and write a consistent reproducible understandable bug report, I really don't know how to help you.
It has been 2 or more weeks with no response on our request for more information. In order for our issue tracker to be effective, we are closing this issue.
If you want it to be reopened again, feel free to supply us with the requested information.
Thanks!
This is an automated comment, triggered by adding the label expired
.
Why set redirectConnectionString to null in function redirect,when the command is complete yii/redis/Connection
e.g.