redis-plus-plus
redis-plus-plus copied to clipboard
[FEATURE] Add support for Redis Functions
Is your feature request related to a problem? Please describe. We use Redis Functions to perform atomic R+W operations in a more ergonomic way than the evalsha API.
Describe the solution you'd like The ability to use redis fcall in redis-plus-plus
Describe alternatives you've considered Transactions, evalsha, and calling out to a separate component with Redis function support
Additional context Thank you so much for making this library!
Thanks for your suggestion! I'll try to add built-in support for Redis Function.
B.T.W. Before that feature is ready, you can use the generic interface to send commands related to Redis Function:
auto r = Redis("redis://127.0.0.1");
auto lib = r.command<string>("FUNCTION", "LOAD",
"#!lua name=mylib\nredis.register_function('knockknock', function() return 'Who\\'s there?' end)");
auto res = r.command<string>("FCALL", "knockknock", 0);
Regards
@sewenew thank you for looking at this! We tried the generic command interface, but there's a problem!
The command interface is treating the first argument to .command as the key. This is a problem in Redis Cluster configurations because our FCALL command calls are being routed to the wrong node/slot.
For example
Server::redis_cluster->command<std::string>("FCALL", "authorize_player_join", 1, to_std_string(tprint("p:%", filled_request->user_id)), g_game_context.server_id);
This command will (almost) always fail, because it's using "authorize_player_join" as the key, instead of the third argument. So, we always get sent to the same (incorrect) Redis host.
You can use the RedisCluster::redis(const StringView &hash_tag, bool new_connection = true)
to work around this problem. Check this issue and the doc for detail.
NOTE: In order to improve performance, you should set new_connection
parameter to be false.
Regards
@sewenew
Thanks for your suggestion! I'll try to add built-in support for Redis Function.
Do you have any updates on this? 🙈
@ivantishchenko Sorry, but there's no progress on this topic. Too busy these days, I'll try it when I'm available. I'll let you know when there's progress.
Regards