Skip to content

mccnlight/my-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

own-redis

Overview

own-redis is a lightweight in-memory key-value store that operates using the UDP protocol. It supports basic database operations: SET, GET, and PING, enabling fast data retrieval and storage.

Learning Objectives

  • TCP/IP & UDP Protocol
  • Basic Networking Concepts
  • Key-Value Database Implementation

Features

  • Fast In-Memory Storage: Data is stored in RAM for quick access.
  • UDP-Based Communication: Each request and response is a single UDP packet.
  • Thread-Safe: Uses Go's sync package to handle parallel requests.
  • Command Case-Insensitivity: Accepts PING, ping, and Ping as equivalent commands.
  • Expiring Keys: SET supports an optional PX (expiry in milliseconds) flag.

Installation & Usage

Build

$ go build -o own-redis .

Run (Default Port: 8080)

$ ./own-redis --port 8080

Usage

$ ./own-redis --help
Own Redis

Usage:
  own-redis [--port <N>]
  own-redis --help

Options:
  --help       Show this screen.
  --port N     Port number.

Supported Commands

PING

Verifies if the server is running.

$ nc 0.0.0.0 8080
PING
PONG

SET

Stores a key-value pair.

$ nc 0.0.0.0 8080
SET foo bar
OK

Supports expiration:

SET foo bar PX 10000

GET

Retrieves a stored value.

$ nc 0.0.0.0 8080
GET foo
bar

If key doesn’t exist:

GET unknown_key
(nil)

Constraints

  • Must adhere to gofumpt formatting.
  • No third-party packages allowed.
  • Must handle errors gracefully (no panics).

License

MIT License

About

Custom Key-Value Database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages