# 02-simple-redis **Repository Path**: czlan91/02-simple-redis ## Basic Information - **Project Name**: 02-simple-redis - **Description**: rust 第二周 (二) - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-05-02 - **Last Updated**: 2024-07-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Geektime Rust 语言训练营 第二周:simple-redis 一个简单的 redis server 实现 ## 依赖 ```shell cargo add anyhow cargo add tokio --features rt --features rt-multi-thread --features macros --features net --features io-util cargo add tracing cargo add tracing-subscriber --features env-filter cargo add bytes cargo add enum_dispatch cargo add thiserror cargo add dashMap cargo add lazy_static cargo add tokio-util --features codec cargo add tokio-stream cargo add futures --no-default-features ``` **可以使用 once_cell 替代 lazy_static** ## 作业 为 simple-redis 实现你想实现的命令,比如: - echo command: https://redis.io/commands/echo/ - hmget command: https://redis.io/commands/hmget/ - sadd/sismember https://redis.io/commands/sismember/ 重构代码: - 删除 NullBulkString / NullArray - 重构 BulkString / RespArray 代码,使其直接处理上面两种情况 ## 启动 ```shell RUST_LOG=info cargo run --bin simple-redis ``` ## 记录 1. echo 命令,使用 simple_string 返回的字符串不带双引号,但是 bulk_string 客户端处理的数据是带有双引号的。 2. redis 7.2.4 的 redis-cli 无法解析 integer ":+0\r\n"; 只能解析:":3\r\n" 3. 删除 NullBulkString / NullArray,使用 Option数据结构,None 表示 NullBulkString / NullArray