diff options
| author | omagdy <omar.professional8777@gmail.com> | 2025-07-24 06:04:32 +0300 |
|---|---|---|
| committer | omagdy <omar.professional8777@gmail.com> | 2025-07-24 06:04:32 +0300 |
| commit | 30e6b478d7cd286b68da21d7a5aa5426c588cd02 (patch) | |
| tree | 719096c1bd3975e192bc5d6608f9f27f98e10e16 /src/rdb.rs | |
| parent | 561fb8d783cc000b7b9cc204e10618464c092e18 (diff) | |
| download | redis-rust-30e6b478d7cd286b68da21d7a5aa5426c588cd02.tar.xz redis-rust-30e6b478d7cd286b68da21d7a5aa5426c588cd02.zip | |
refactor: Refactor how I model the state and config and cache of the server with sepraration of concerns
Diffstat (limited to 'src/rdb.rs')
| -rw-r--r-- | src/rdb.rs | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -600,6 +600,20 @@ impl FromBytes for RDBFile { let mut total_consumed = 0; let mut databases = HashMap::new(); + // special case when rdb file is sent by the master to replicas in the following format + // $<length>/r/n<bytes_of_length_length> + if bytes[0] == '$' as u8 { + // consume up to the CRLF + let (consumed, rest) = bytes + .windows(2) + .position(|window| window == b"\r\n") + .map(|pos| (&bytes[..pos], &bytes[pos + 2..])) + .ok_or(ParseError::UnexpectedEof)?; + println!("Consumed {:?}", consumed); + remaining = rest; + total_consumed += consumed.len(); + } + // 1. Parse the RDB header ("REDIS" + version) let (header, consumed) = RDBHeader::from_bytes(remaining)?; total_consumed += consumed; |
