diff options
| author | omagdy <omar.professional8777@gmail.com> | 2025-07-23 02:42:31 +0300 |
|---|---|---|
| committer | omagdy <omar.professional8777@gmail.com> | 2025-07-23 02:42:31 +0300 |
| commit | 21a90f12690729f3f4aaca64d413e9e5d8dc0bd4 (patch) | |
| tree | c68d7c6c56e3d4b6db95d4226f8dfb664b3c0dc2 /src/resp_commands.rs | |
| parent | d4dbbda97b42bad8a41297ba1c3a693f1fe66902 (diff) | |
| download | redis-rust-21a90f12690729f3f4aaca64d413e9e5d8dc0bd4.tar.xz redis-rust-21a90f12690729f3f4aaca64d413e9e5d8dc0bd4.zip | |
feat: Added first step in handshake process between replicas(slaves) and master nodes
Diffstat (limited to 'src/resp_commands.rs')
| -rw-r--r-- | src/resp_commands.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/resp_commands.rs b/src/resp_commands.rs index 2c9c09c..554c296 100644 --- a/src/resp_commands.rs +++ b/src/resp_commands.rs @@ -124,8 +124,8 @@ impl RedisCommands { pub fn execute(self, cache: SharedCache, config: SharedConfig) -> Vec<u8> { use RedisCommands as RC; match self { - RC::Ping => resp!("PONG"), - RC::Echo(echo_string) => resp!(echo_string), + RC::Ping => resp_bytes!("PONG"), + RC::Echo(echo_string) => resp_bytes!(echo_string), RC::Get(key) => { let mut cache = cache.lock().unwrap(); @@ -133,12 +133,12 @@ impl RedisCommands { Some(entry) => { if entry.is_expired() { cache.remove(&key); // Clean up expired key - resp!(null) + resp_bytes!(null) } else { - resp!(bulk entry.value) + resp_bytes!(bulk entry.value) } } - None => resp!(null), + None => resp_bytes!(null), } } RC::Set(command) => { @@ -149,10 +149,10 @@ impl RedisCommands { match command.condition { Some(SetCondition::NotExists) if key_exists => { - return resp!(null); // Key exists, NX failed + return resp_bytes!(null); // Key exists, NX failed } Some(SetCondition::Exists) if !key_exists => { - return resp!(null); // Key doesn't exist, XX failed + return resp_bytes!(null); // Key doesn't exist, XX failed } _ => {} // No condition or condition met } @@ -186,12 +186,12 @@ impl RedisCommands { ); if !command.get_old_value { - return resp!("OK"); + return resp_bytes!("OK"); } match get_value { - Some(val) => return resp!(bulk val), - None => return resp!(null), + Some(val) => return resp_bytes!(bulk val), + None => return resp_bytes!(null), } } RC::ConfigGet(s) => { |
