sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.64k stars 351 forks source link

[FEATURE] Allow specifying the keepalive interval #453

Closed wb2712 closed 1 year ago

wb2712 commented 1 year ago

hiredis Allow specifying the keepalive interval #1168

sewenew commented 1 year ago

Thanks for the suggestion! I'll take a look on how to implement it. It seems not an easy fix, since we need to ensure the code can work compatibly with old version of hiredis, i.e. hiredis without such an interface.

I'll let you know, if I get some progress.

Regrads

sewenew commented 1 year ago

I've added support for this feature. You can try the latest code on dev branch. Also you should install the latest hiredis on master branch to have this support.

ConnectionOptions opts;
opts.host = "127.0.0.1";
opts.port = 6379;
opts.keep_alive_s = std::chrono::seconds(1);
auto r = Redis(opts);

Since this is a new API for hiredis, I need to use cmake to check if this feature is supported, and dynamically create a hiredis_features.h which includes some feature testing macro. Not sure if this is the best way to make the code compatible with hiredis of any version. So I need to make some more tests and do some more research before merging the code into master branch. If you have any feedback on the implementation, feel free to let me know :)

Sorry for the late reply, too busy these days...

Regards

sewenew commented 1 year ago

Code has been merged into master branch.

Regards