refactor: modified RedisDataConn have a pool and RedisDataConn#get_connection get conn from pool #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR modifies
RedisDataConn#get_connectionto retrieve a connection fromr2d2::Pool<RedlisClient>, not to get a same connection instance that was created along with theRedisDataConn.In the previous implementation, while the borrow of the
conn: redis::Connectioninstance obtained fromRedisDataConn#get_connectionwas active, you couldn't call theRedisDataConn#add_force_back method. To perform multiple operations and register force-back functions alternately, you had to enclose theconnacquisition and operations in a block. After the block ended and theconnwas dropped, you could then executeadd_force_back, and then repeat the process of acquiring theconnand performing operations inside another block.In the new implementation, it's possible to execute operations on the
connandadd_force_backalternately.Also, in the previous implementation, it was impossible to handle a connection that was severed while being passed around. With the new implementation, however, the pool automatically reconnects, allowing you to get an active connection by calling
RedisDataConn::get_connection.However, if all connections are in use, there will be an overhead of waiting until a connection is released.