redis2_raw_query
The redis2_raw_query directive sends a raw query string to a Redis server as part of an NGINX configuration.
Description
The redis2_raw_query directive allows for the submission of a raw, pre-formatted Redis command directly from the NGINX configuration. This is useful for cases where you need to construct complex Redis commands that may not line up with traditional method calls or when you want to leverage existing command syntaxes without additional parsing in the configuration layer. By specifying this directive, users can craft their queries in the format recognized by Redis, which may include multi-bulk commands, and send them directly to the Redis server without any modification.
The directive accepts one argument, which is a string containing the Redis command. The command must follow the standard Redis protocol format, including the appropriate CRLF (Carriage Return and Line Feed) sequence. For instance, a basic command to retrieve a value might be structured as `get key
`. This direct approach is particularly beneficial for advanced command implementations or optimizations where utilizing native Redis commands is preferred over the conventional NGINX API calls.
Config Example
location = /bar {
redis2_raw_query 'get one
';
redis2_pass 127.0.0.1:6379;
}Ensure that the command string is properly formatted according to Redis protocol; otherwise, Redis will return an error.
The command must end with the CRLF sequence to be recognized as valid by the Redis server.
Using this directive incorrectly may lead to unexpected behavior since the command is sent as a raw string.