Skip to content

rrronit/pulse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis-like Server in Rust

This project is a simple Redis-like server implemented in Rust. It supports a subset of Redis commands and can be used as a lightweight in-memory key-value store.

Features

  • Supported Commands:
    • GET: Retrieve the value of a key.
    • SET: Set the value of a key.
    • DEL: Delete a key.
    • EXISTS: Check if a key exists.
    • KEYS: List all keys matching a pattern.
    • INCR: Increment the integer value of a key.
    • DECR: Decrement the integer value of a key.
    • PING: Respond with PONG.
    • ECHO: Echo back the provided argument.
    • FLUSHALL: Clear all keys in the database.
    • GETALL: Retrieve all keys and values in the database.
    • QUIT: Close the connection.

Getting Started

Usage

redis-cli -h 127.0.0.1 -p 6380

Example Commands

  • Set a key:

    SET mykey "Hello"
    
  • Get a key:

    GET mykey
    
  • Delete a key:

    DEL mykey
    
  • Check if a key exists:

    EXISTS mykey
    
  • List all keys:

    KEYS *
    
  • Increment a key:

    INCR counter
    
  • Decrement a key:

    DECR counter
    
  • Ping the server:

    PING
    
  • Echo a message:

    ECHO "Hello, World!"
    
  • Flush all keys:

    FLUSHALL
    
  • Get all keys and values:

    GETALL
    
  • Quit the session:

    QUIT
    

Code Structure

  • src/core/: Contains the core logic for handling commands and managing the database.

    • cmd.rs: Defines the Commands enum and command handlers.
    • db.rs: Implements the in-memory database.
    • expiry.rs: (Optional) Handles key expiration.
    • resp_parser.rs: Parses Redis Serialization Protocol (RESP) messages.
    • resp_encoder.rs: Encodes responses in RESP format.
  • src/server.rs: Implements the TCP server and connection handling.


About

Redis-like Server Implemented in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages