Git Product home page Git Product logo

lil-redis's Introduction

lil-redis

An intentionally-limited Rust implementation of the Redis server.

lil redis is an accessible implementation of a very basic Redis server (with ping, echo, get, and basic set support), with no external dependencies (other than tokio and anyhow).

Motivation

I've been trying to get more serious about learning Rust lately, and what better way to learn than by debugging. So, when I discovered CodeCrafters (a platform that helps you get better at coding by guiding you through rebuilding popular tools, referral link w/ discount), I decided to give their Redis guide a try.

Since the platform encourages you to come up with your own implementations, I've tried my best to make things as clean as possible (while hopefully keeping it simple enough for a beginner to understand). If you want to try your hand at it, I'd recommend going through the guide first, then comparing your solution to this one.

By sharing my implementation publicly, I hope to both attract others interested in learning Rust (who can use it as a learning resource) and already proficient with it (who can share which things they'd have done differently. PRs welcome!).

Structure

The codebase is structured as follows:

lil-redis/
├─ src/
│ ├─ app.rs: TCP server, listening for connections, receiving and sending data.
│ ├─ cache.rs: Simple string store with built-in TTL support.
│ ├─ commands.rs: Redis command definition, parsing and logic.
│ ├─ main.rs: What gets called when you run the project
│ ├─ resp.rs: Encoding and decoding for Redis' RESP protocol
│ ├─ utils.rs: Helper functions
├─ tests/
│ ├─ redis_test.rs: Integration tests ensuring our server responds to requests by a Redis client
├─ Cargo.toml
├─ README.md

If you want to explore the codebase, I'd recommend starting with the main.rs file and going from there

Note You can press . while on GitHub to launch a web VSCode instance, which should help you navigate the project better.

Develop

Make sure you have the latest version of rust installed (use rustup). Then, you can build the project by running cargo build, run it with cargo run, and run the tests with cargo test.

License

This project is open-sourced under the MIT license. See the License file for more information.

lil-redis's People

Contributors

m1guelpf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

srivastava-yash

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.