### Building and Starting Corvus Proxy Source: https://context7.com/eleme/corvus/llms.txt Instructions for cloning the Corvus repository, updating submodules, installing dependencies, building the proxy from source, and starting the proxy with a configuration file. The output indicates the address and port the proxy is serving on. ```bash # Build from source git clone https://github.com/eleme/corvus.git cd corvus git submodule update --init make deps make # Start the proxy ./src/corvus /path/to/corvus.conf # Output: serve at 0.0.0.0:12345 ``` -------------------------------- ### Python Client Example with Corvus Proxy (redis-py) Source: https://context7.com/eleme/corvus/llms.txt This Python example demonstrates how to use the redis-py library to interact with the Corvus proxy. It covers basic connection, authentication, and standard Redis operations like SET, GET, MSET, MGET, pipelines, hash operations, sorted sets, and expiration. ```python import redis # Connect to Corvus proxy instead of Redis directly r = redis.Redis(host='localhost', port=12345) # With authentication r = redis.Redis(host='localhost', port=12345, password='mypassword') # Basic operations work exactly like direct Redis connection r.set('mykey', 'Hello World') value = r.get('mykey') print(value) # b'Hello World' # Multi-key operations are transparently handled r.mset({'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}) values = r.mget('key1', 'key2', 'key3') print(values) # [b'val1', b'val2', b'val3'] # Pipeline support pipe = r.pipeline() pipe.set('a', 1) pipe.set('b', 2) pipe.get('a') pipe.get('b') results = pipe.execute() print(results) # [True, True, b'1', b'2'] # Hash operations r.hset('user:1', mapping={'name': 'John', 'age': '30'}) user = r.hgetall('user:1') print(user) # {b'name': b'John', b'age': b'30'} # Sorted sets r.zadd('leaderboard', {'player1': 100, 'player2': 200}) top = r.zrange('leaderboard', 0, -1, withscores=True) print(top) # [(b'player1', 100.0), (b'player2', 200.0)] # Expiration r.setex('temp_key', 60, 'temporary value') ttl = r.ttl('temp_key') print(f'TTL: {ttl} seconds') # TTL: 60 seconds ``` -------------------------------- ### Python Client Example Source: https://context7.com/eleme/corvus/llms.txt Example demonstrating how to use the standard redis-py library to interact with the Corvus proxy. Shows connection, basic operations, and advanced features like pipelines and hash operations. ```APIDOC ## Python Client Example ### Description Demonstrates using the `redis-py` library with the Corvus proxy. ### Language Python ### Code Example ```python import redis # Connect to Corvus proxy instead of Redis directly r = redis.Redis(host='localhost', port=12345) # With authentication r = redis.Redis(host='localhost', port=12345, password='mypassword') # Basic operations work exactly like direct Redis connection r.set('mykey', 'Hello World') value = r.get('mykey') print(value) # b'Hello World' # Multi-key operations are transparently handled r.mset({'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}) values = r.mget('key1', 'key2', 'key3') print(values) # [b'val1', b'val2', b'val3'] # Pipeline support pipe = r.pipeline() pipe.set('a', 1) pipe.set('b', 2) pipe.get('a') pipe.get('b') results = pipe.execute() print(results) # [True, True, b'1', b'2'] # Hash operations r.hset('user:1', mapping={'name': 'John', 'age': '30'}) user = r.hgetall('user:1') print(user) # {b'name': b'John', b'age': b'30'} # Sorted sets r.zadd('leaderboard', {'player1': 100, 'player2': 200}) top = r.zrange('leaderboard', 0, -1, withscores=True) print(top) # [(b'player1', 100.0), (b'player2', 200.0)] # Expiration r.setex('temp_key', 60, 'temporary value') ttl = r.ttl('temp_key') print(f'TTL: {ttl} seconds') # TTL: 60 seconds ``` ``` -------------------------------- ### Corvus Configuration File Example Source: https://context7.com/eleme/corvus/llms.txt Example of a main configuration file for Corvus. It defines settings such as the bind port, Redis cluster seed nodes, worker threads, log level, timeouts, authentication, read strategy, statsd integration, and slowlog configuration. ```bash # corvus.conf - Main configuration file # Port to bind the proxy bind 12345 # Redis cluster seed nodes (comma-separated) node localhost:8000,localhost:8001,localhost:8002 # Number of worker threads thread 4 # Log level: debug, info, warn, error loglevel info syslog 0 # Connection timeouts (0 = never timeout) client_timeout 30 server_timeout 5 # Optional authentication requirepass mypassword # Read strategy: master, read-slave-only, both read-strategy master # Statsd metrics integration statsd localhost:8125 metric_interval 10 cluster default # Slowlog configuration slowlog-log-slower-than 10000 slowlog-max-len 1024 slowlog-statsd-enabled 0 # Buffer size (default 16384, min 64) bufsize 16384 ``` -------------------------------- ### EVAL (Lua Scripting) with Corvus Proxy Source: https://context7.com/eleme/corvus/llms.txt Shows how to execute Lua scripts using the EVAL command through the Corvus proxy. It highlights that scripts require at least one key, and all keys must belong to the same cluster node. Examples include simple GET, incrementing a value, and multi-key operations using hash tags. ```redis # Simple EVAL with single key 127.0.0.1:12345> EVAL "return redis.call('GET', KEYS[1])" 1 mykey "Hello World" # Increment with Lua script 127.0.0.1:12345> EVAL "local val = redis.call('GET', KEYS[1]) or 0; return redis.call('SET', KEYS[1], val + ARGV[1])" 1 counter 5 OK # Multi-key operations (keys must hash to same slot using hash tags) 127.0.0.1:12345> EVAL "redis.call('SET', KEYS[1], ARGV[1]); redis.call('SET', KEYS[2], ARGV[2]); return 'OK'" 2 {user}:name {user}:age "John" 30 "OK" ``` -------------------------------- ### Run Corvus Proxy Source: https://github.com/eleme/corvus/blob/master/README.md Command to start the Corvus proxy with a specified configuration file. This is the primary way to launch the proxy for use. ```bash ./src/corvus path/to/corvus.conf ``` -------------------------------- ### Run Redis GET Benchmark Source: https://github.com/eleme/corvus/blob/master/docs/redis_benchmarks/get.md Executes a benchmark test for the Redis GET command. It specifies the Redis server host and port, the number of requests, the key range, the operation type ('get'), the pipeline size, and the number of parallel clients. The output provides performance statistics. ```bash redis-benchmark -h 10.0.16.72 -p 8802 -n 90000000 -r 90000000 -t get -P 1000 -c 100 ``` -------------------------------- ### CONFIG Command Source: https://context7.com/eleme/corvus/llms.txt Retrieve and modify proxy configuration at runtime. Supports getting and setting configuration values, and rewriting the configuration to disk. ```APIDOC ## CONFIG Command ### Description Retrieves and modifies proxy configuration at runtime. ### Method GET/POST (Implicit) ### Endpoint / ### Parameters #### Query Parameters - **GET** (string) - The configuration parameter to retrieve (e.g., `thread`, `node`, `slowlog-log-slower-than`). - **SET** (string) - The configuration parameter to set and its new value. - **REWRITE** (none) - Rewrites the current configuration to disk. ### Request Example ```bash # Get configuration value 127.0.0.1:12345> CONFIG GET thread # Set configuration value 127.0.0.1:12345> CONFIG SET node 192.168.1.10:6379,192.168.1.11:6379 # Rewrite configuration to disk 127.0.0.1:12345> CONFIG REWRITE ``` ### Response #### Success Response (200) - **GET**: The value of the requested configuration parameter. - **SET**: "OK" upon successful update. - **REWRITE**: "OK" upon successful rewrite. #### Response Example (GET thread) ``` "4" ``` #### Response Example (SET node) ``` OK ``` #### Response Example (REWRITE) ``` OK ``` ``` -------------------------------- ### Get Corvus Proxy Statistics (INFO Command) Source: https://context7.com/eleme/corvus/llms.txt The INFO command retrieves statistics about the Corvus proxy, including version, threads, memory usage, connected clients, and network traffic. It does not return backend Redis information. ```bash 127.0.0.1:12345> INFO cluster:default version:0.2.7 pid:12345 threads:4 mem_allocator:jemalloc-4.2.1 used_cpu_sys:1.23 used_cpu_user:2.34 connected_clients:15 completed_commands:123456 slot_update_jobs:0 recv_bytes:1234567 send_bytes:2345678 remote_latency:0.000123 total_latency:0.000456 last_command_latency:0.000100,0.000110,0.000095,0.000105 ask_recv:0 moved_recv:10 remotes:127.0.0.1:8000,127.0.0.1:8001,127.0.0.1:8002 ``` -------------------------------- ### Corvus Restricted Multi-Key Commands with Hash Tags Source: https://context7.com/eleme/corvus/llms.txt Certain commands in Corvus require all involved keys to reside on the same backend node. Hash tags, enclosed in curly braces `{tag}`, are used to ensure keys hash to the same slot, enabling these commands. Examples include SORT with STORE, and set/sorted set operations. ```bash # Hash tags ensure keys hash to same slot # Format: {tag}keyname - only {tag} is used for slot calculation # SORT with STORE (keys must be on same node) 127.0.0.1:12345> LPUSH {mydata}list 3 1 2 (integer) 3 127.0.0.1:12345> SORT {mydata}list STORE {mydata}sorted (integer) 3 127.0.0.1:12345> LRANGE {mydata}sorted 0 -1 1) "1" 2) "2" 3) "3" # Set operations across keys 127.0.0.1:12345> SADD {sets}a 1 2 3 (integer) 3 127.0.0.1:12345> SADD {sets}b 2 3 4 (integer) 3 127.0.0.1:12345> SINTER {sets}a {sets}b 1) "2" 2) "3" 127.0.0.1:12345> SUNION {sets}a {sets}b 1) "1" 2) "2" 3) "3" 4) "4" # Sorted set operations 127.0.0.1:12345> ZADD {zsets}a 1 "one" 2 "two" (integer) 2 127.0.0.1:12345> ZADD {zsets}b 2 "two" 3 "three" (integer) 2 127.0.0.1:12345> ZINTERSTORE {zsets}out 2 {zsets}a {zsets}b (integer) 1 127.0.0.1:12345> ZRANGE {zsets}out 0 -1 WITHSCORES 1) "two" 2) "4" ``` -------------------------------- ### Manage Corvus Proxy Operations (PROXY Command) Source: https://context7.com/eleme/corvus/llms.txt The PROXY command provides Corvus-specific functionalities for proxy management and diagnostics. It can be used to get detailed memory statistics or to force updates of the slot map from the cluster. ```bash # Get detailed proxy memory statistics 127.0.0.1:12345> PROXY INFO in_use_buffers:128 free_buffers:64 in_use_cmds:10 free_cmds:1014 in_use_conns:15 free_conns:5 in_use_conn_info:20 free_conn_info:10 in_use_buf_times:5 free_buf_times:95 # Force slot map update from cluster 127.0.0.1:12345> PROXY UPDATESLOTMAP OK ``` -------------------------------- ### Get Current Server Time (TIME Command) Source: https://context7.com/eleme/corvus/llms.txt The TIME command returns the current server time as a Unix timestamp in seconds and microseconds. This operation is handled by the proxy and does not involve forwarding to backend Redis nodes. ```bash 127.0.0.1:12345> TIME 1) "1464233596" # Unix timestamp in seconds 2) "123456" # Microseconds ``` -------------------------------- ### Build Corvus Proxy Source: https://github.com/eleme/corvus/blob/master/README.md Instructions for building the Corvus proxy from source or using pre-compiled releases. It covers standard builds, debug mode, and dependency management. ```bash $ make ``` ```bash make debug ``` ```bash git clone https://github.com/eleme/corvus.git cd corvus git submodule update --init make deps # need autoconf make ``` -------------------------------- ### Basic Redis Commands via Corvus Proxy Source: https://context7.com/eleme/corvus/llms.txt Demonstrates how to connect to the Corvus proxy using redis-cli and execute various basic Redis commands. Corvus transparently routes single-key commands to the correct cluster node. ```redis # Connect to Corvus proxy using redis-cli redis-cli -p 12345 # String operations 127.0.0.1:12345> SET mykey "Hello World" OK 127.0.0.1:12345> GET mykey "Hello World" 127.0.0.1:12345> INCR counter (integer) 1 127.0.0.1:12345> APPEND mykey " - appended" (integer) 22 # Key expiration 127.0.0.1:12345> EXPIRE mykey 60 (integer) 1 127.0.0.1:12345> TTL mykey (integer) 60 127.0.0.1:12345> PTTL mykey (integer) 59987 # Hash operations 127.0.0.1:12345> HSET user:1 name "John" age 30 (integer) 2 127.0.0.1:12345> HGET user:1 name "John" 127.0.0.1:12345> HGETALL user:1 1) "name" 2) "John" 3) "age" 4) "30" # List operations 127.0.0.1:12345> LPUSH mylist "world" (integer) 1 127.0.0.1:12345> LPUSH mylist "hello" (integer) 2 127.0.0.1:12345> LRANGE mylist 0 -1 1) "hello" 2) "world" # Set operations 127.0.0.1:12345> SADD myset "a" "b" "c" (integer) 3 127.0.0.1:12345> SMEMBERS myset 1) "a" 2) "b" 3) "c" # Sorted set operations 127.0.0.1:12345> ZADD leaderboard 100 "player1" 200 "player2" (integer) 2 127.0.0.1:12345> ZRANGE leaderboard 0 -1 WITHSCORES 1) "player1" 2) "100" 3) "player2" 4) "200" ``` -------------------------------- ### Configure Corvus Proxy at Runtime (CONFIG Command) Source: https://context7.com/eleme/corvus/llms.txt The CONFIG command allows retrieving and modifying proxy configuration parameters at runtime. Some options, like 'node', can be set, while others might be read-only. CONFIG REWRITE persists changes to disk. ```bash # Get configuration value 127.0.0.1:12345> CONFIG GET thread "4" 127.0.0.1:12345> CONFIG GET node "localhost:8000,localhost:8001,localhost:8002" 127.0.0.1:12345> CONFIG GET slowlog-log-slower-than "10000" # Set configuration (limited options) 127.0.0.1:12345> CONFIG SET node 192.168.1.10:6379,192.168.1.11:6379 OK # Rewrite configuration to disk 127.0.0.1:12345> CONFIG REWRITE OK ``` -------------------------------- ### Corvus Handling of Multi-Key Redis Commands Source: https://context7.com/eleme/corvus/llms.txt Illustrates how Corvus transparently handles multi-key commands like MSET, MGET, DEL, and EXISTS. Corvus splits these into single-key operations, routes them to the appropriate cluster nodes, and aggregates the results. ```redis # MSET - split into multiple SET commands 127.0.0.1:12345> MSET key1 "value1" key2 "value2" key3 "value3" OK # MGET - split into multiple GET commands, results aggregated 127.0.0.1:12345> MGET key1 key2 key3 nonexistent 1) "value1" 2) "value2" 3) "value3" 4) (nil) # DEL - split into multiple single-key DEL commands # Returns total count of deleted keys 127.0.0.1:12345> DEL key1 key2 key3 (integer) 3 # EXISTS - split into multiple single-key EXISTS commands # Returns count of existing keys 127.0.0.1:12345> SET a 1 OK 127.0.0.1:12345> SET b 2 OK 127.0.0.1:12345> EXISTS a b nonexistent (integer) 2 ``` -------------------------------- ### Restricted Multi-Key Commands Source: https://context7.com/eleme/corvus/llms.txt Details on how to handle multi-key commands in Corvus. Commands requiring all keys on the same node must use hash tags to ensure co-location. ```APIDOC ## Restricted Multi-Key Commands ### Description Explains the use of hash tags for multi-key commands that require keys to be on the same node. ### Method N/A (Applies to various commands) ### Endpoint N/A ### Parameters N/A ### Key Concept: Hash Tags Hash tags ensure keys hash to the same slot by enclosing a part of the key in curly braces `{}`. Only the content within the braces is used for slot calculation. ### Examples #### SORT with STORE ```bash 127.0.0.1:12345> LPUSH {mydata}list 3 1 2 (integer) 3 127.0.0.1:12345> SORT {mydata}list STORE {mydata}sorted (integer) 3 127.0.0.1:12345> LRANGE {mydata}sorted 0 -1 1) "1" 2) "2" 3) "3" ``` #### Set Operations ```bash 127.0.0.1:12345> SADD {sets}a 1 2 3 (integer) 3 127.0.0.1:12345> SADD {sets}b 2 3 4 (integer) 3 127.0.0.1:12345> SINTER {sets}a {sets}b 1) "2" 2) "3" 127.0.0.1:12345> SUNION {sets}a {sets}b 1) "1" 2) "2" 3) "3" 4) "4" ``` #### Sorted Set Operations ```bash 127.0.0.1:12345> ZADD {zsets}a 1 "one" 2 "two" (integer) 2 127.0.0.1:12345> ZADD {zsets}b 2 "two" 3 "three" (integer) 2 127.0.0.1:12345> ZINTERSTORE {zsets}out 2 {zsets}a {zsets}b (integer) 1 127.0.0.1:12345> ZRANGE {zsets}out 0 -1 WITHSCORES 1) "two" 2) "4" ``` ``` -------------------------------- ### INFO Command Source: https://context7.com/eleme/corvus/llms.txt The INFO command returns proxy statistics rather than backend Redis information. It provides details about the proxy's version, threads, memory usage, client connections, command execution counts, and network traffic. ```APIDOC ## INFO Command ### Description Returns proxy statistics rather than backend Redis information. ### Method GET (Implicit) ### Endpoint / ### Parameters None ### Request Example ``` 127.0.0.1:12345> INFO ``` ### Response #### Success Response (200) - **cluster** (string) - The cluster name. - **version** (string) - The proxy version. - **pid** (integer) - The process ID of the proxy. - **threads** (integer) - The number of threads used by the proxy. - **mem_allocator** (string) - The memory allocator used. - **used_cpu_sys** (number) - CPU time used by the system. - **used_cpu_user** (number) - CPU time used by the user. - **connected_clients** (integer) - The number of connected clients. - **completed_commands** (integer) - The total number of commands completed. - **slot_update_jobs** (integer) - Number of slot update jobs. - **recv_bytes** (integer) - Total bytes received. - **send_bytes** (integer) - Total bytes sent. - **remote_latency** (number) - Average remote latency. - **total_latency** (number) - Average total latency. - **last_command_latency** (string) - Latency details for the last few commands. - **ask_recv** (integer) - Number of ASK redirections received. - **moved_recv** (integer) - Number of MOVED redirections received. - **remotes** (string) - List of backend Redis nodes. #### Response Example ``` cluster:default version:0.2.7 pid:12345 threads:4 mem_allocator:jemalloc-4.2.1 used_cpu_sys:1.23 used_cpu_user:2.34 connected_clients:15 completed_commands:123456 slot_update_jobs:0 recv_bytes:1234567 send_bytes:2345678 remote_latency:0.000123 total_latency:0.000456 last_command_latency:0.000100,0.000110,0.000095,0.000105 ask_recv:0 moved_recv:10 remotes:127.0.0.1:8000,127.0.0.1:8001,127.0.0.1:8002 ``` ``` -------------------------------- ### Authenticate with Corvus Proxy (AUTH Command) Source: https://context7.com/eleme/corvus/llms.txt Authentication is handled directly by the Corvus proxy. The AUTH command is used to authenticate a client connection with a password. If authentication is required and not provided, commands will result in a NOAUTH error. ```bash # With requirepass configured 127.0.0.1:12345> GET mykey (error) NOAUTH Authentication required. 127.0.0.1:12345> AUTH wrongpassword (error) ERR invalid password 127.0.0.1:12345> AUTH correctpassword OK 127.0.0.1:12345> GET mykey "Hello World" ``` -------------------------------- ### AUTH Command Source: https://context7.com/eleme/corvus/llms.txt Authentication is handled at the proxy level without forwarding to backend Redis nodes. This command is used to authenticate clients. ```APIDOC ## AUTH Command ### Description Handles client authentication at the proxy level. ### Method POST (Implicit) ### Endpoint / ### Parameters #### Query Parameters - **password** (string) - The password for authentication. ### Request Example ```bash 127.0.0.1:12345> AUTH correctpassword ``` ### Response #### Success Response (200) - **OK** #### Error Response - **(error) NOAUTH Authentication required.** - **(error) ERR invalid password** #### Response Example ``` OK ``` ``` -------------------------------- ### PROXY Command Source: https://context7.com/eleme/corvus/llms.txt Corvus-specific commands for proxy management and diagnostics. Includes commands for retrieving memory statistics and forcing slot map updates. ```APIDOC ## PROXY Command ### Description Corvus-specific commands for proxy management and diagnostics. ### Method GET/POST (Implicit) ### Endpoint / ### Parameters #### Query Parameters - **INFO** (none) - Retrieves detailed proxy memory statistics. - **UPDATESLOTMAP** (none) - Forces a slot map update from the cluster. ### Request Example ```bash # Get detailed proxy memory statistics 127.0.0.1:12345> PROXY INFO # Force slot map update from cluster 127.0.0.1:12345> PROXY UPDATESLOTMAP ``` ### Response #### Success Response (200) - **INFO**: Detailed memory statistics including buffer usage, command counts, and connection information. - **UPDATESLOTMAP**: "OK" upon successful update. #### Response Example (INFO) ``` in_use_buffers:128 free_buffers:64 in_use_cmds:10 free_cmds:1014 in_use_conns:15 free_conns:5 in_use_conn_info:20 free_conn_info:10 in_use_buf_times:5 free_buf_times:95 ``` #### Response Example (UPDATESLOTMAP) ``` OK ``` ``` -------------------------------- ### TIME Command Source: https://context7.com/eleme/corvus/llms.txt Returns the current server time without forwarding to backend Redis. The time is provided as a Unix timestamp and microseconds. ```APIDOC ## TIME Command ### Description Returns the current server time. ### Method GET (Implicit) ### Endpoint / ### Parameters None ### Request Example ```bash 127.0.0.1:12345> TIME ``` ### Response #### Success Response (200) - **Array**: Contains two elements: Unix timestamp in seconds and microseconds. #### Response Example ``` 1) "1464233596" 2) "123456" ``` ``` -------------------------------- ### Manage Corvus Slowlog (SLOWLOG Command) Source: https://context7.com/eleme/corvus/llms.txt Corvus maintains an independent slowlog to track commands exceeding a specified latency. The SLOWLOG command allows retrieving entries, checking the log length, and resetting the log. Configuration for slowlog is done in the Corvus configuration file. ```bash # Enable slowlog in config: # slowlog-log-slower-than 10000 (microseconds) # slowlog-max-len 1024 # Get slowlog entries 127.0.0.1:12345> SLOWLOG GET 10 1) 1) (integer) 1 # log id 2) (integer) 1464233596 # timestamp 3) (integer) 5000 # remote latency (us) 4) (integer) 15000 # total latency (us) 5) 1) "GET" # command 2) "mykey" # Get slowlog length 127.0.0.1:12345> SLOWLOG LEN (integer) 42 # Reset slowlog 127.0.0.1:12345> SLOWLOG RESET OK ``` -------------------------------- ### SLOWLOG Command Source: https://context7.com/eleme/corvus/llms.txt Corvus maintains its own slowlog independent of backend Redis nodes, with an additional remote latency field. This command allows retrieval and management of slowlog entries. ```APIDOC ## SLOWLOG Command ### Description Manages and retrieves slowlog entries, including remote latency information. ### Method GET/POST (Implicit) ### Endpoint / ### Parameters #### Query Parameters - **GET** (integer) - Optional. Number of slowlog entries to retrieve. - **LEN** (none) - Optional. Retrieves the length of the slowlog. - **RESET** (none) - Optional. Resets the slowlog. ### Request Example ```bash 127.0.0.1:12345> SLOWLOG GET 10 ``` ### Response #### Success Response (200) - **GET**: A list of slowlog entries, each containing log ID, timestamp, remote latency, total latency, and the command. - **LEN**: An integer representing the number of entries in the slowlog. - **RESET**: "OK" upon successful reset. #### Response Example (GET 10) ``` 1) 1) (integer) 1 2) (integer) 1464233596 3) (integer) 5000 4) (integer) 15000 5) 1) "GET" 2) "mykey" ``` #### Response Example (LEN) ``` (integer) 42 ``` #### Response Example (RESET) ``` OK ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.