|
16 | 16 | #include <userver/storages/redis/request.hpp>
|
17 | 17 | #include <userver/storages/redis/request_eval.hpp>
|
18 | 18 | #include <userver/storages/redis/request_evalsha.hpp>
|
| 19 | +#include <userver/storages/redis/request_generic.hpp> |
19 | 20 | #include <userver/storages/redis/transaction.hpp>
|
20 | 21 |
|
21 | 22 | USERVER_NAMESPACE_BEGIN
|
@@ -107,6 +108,22 @@ class Client {
|
107 | 108 | EvalShaCommon(std::move(script_hash), std::move(keys), std::move(args), command_control)};
|
108 | 109 | }
|
109 | 110 |
|
| 111 | + /// @brief Execute a custom Redis command. |
| 112 | + /// @param key_index Index of the key in the args vector used to determine the shard |
| 113 | + /// |
| 114 | + /// Sample usage: |
| 115 | + /// @snippet redis/src/storages/redis/client_cluster_redistest.cpp Sample generic command usage |
| 116 | + template <typename ReplyType> |
| 117 | + RequestGeneric<ReplyType> GenericCommand( |
| 118 | + std::string command, |
| 119 | + std::vector<std::string> args, |
| 120 | + size_t key_index, |
| 121 | + const CommandControl& command_control |
| 122 | + ) { |
| 123 | + return RequestGeneric<ReplyType>{ |
| 124 | + GenericCommon(std::move(command), std::move(args), key_index, command_control)}; |
| 125 | + } |
| 126 | + |
110 | 127 | /// @brief Load the script to the server for further execution via EvalSha() member function.
|
111 | 128 | ///
|
112 | 129 | /// Sample usage:
|
@@ -517,6 +534,12 @@ class Client {
|
517 | 534 | std::vector<std::string> args,
|
518 | 535 | const CommandControl& command_control
|
519 | 536 | ) = 0;
|
| 537 | + virtual RequestGenericCommon GenericCommon( |
| 538 | + std::string command, |
| 539 | + std::vector<std::string> args, |
| 540 | + size_t key_index, |
| 541 | + const CommandControl& command_control |
| 542 | + ) = 0; |
520 | 543 | };
|
521 | 544 |
|
522 | 545 | std::string CreateTmpKey(const std::string& key, std::string prefix);
|
|
0 commit comments