Skip to content

mradulnatani/cacheieee

Repository files navigation

cacheieee

cacheieee is a lightweight, blazing-fast in-memory key-value data store written in C. Inspired by Redis, cacheieee provides essential caching capabilities and gives developers a behind-the-scenes look at how high-performance caching systems are built — from TCP networking and socket management to memory storage and command parsing.


Features

  • Basic key-value operations: SET, GET, DEL, EXISTS
  • Key expiration with TTL support: SETEX, TTL
  • Pattern matching for keys: KEYS
  • Atomic integer operations: INCR, DECR
  • Multi-client support using TCP sockets
  • Tree-based key-value storage for efficient lookups (in progress)
  • Clean command parsing for simplicity and efficiency
  • Comprehensive CLI testing support
  • Built from scratch in C for learning systems-level programming

Supported Commands

Command Description
SET key value Sets the value for the given key
GET key Retrieves the value associated with the key
DEL key Deletes the key and its value
EXISTS key Checks if the key exists in the store
KEYS pattern Returns all keys matching the given pattern (e.g., *, user*, etc.)
SETEX key ttl value Sets a value with a TTL (in seconds)
TTL key Returns the remaining time to live (TTL) for a key
INCR key Increments an integer value by 1
DECR key Decrements an integer value by 1
PING Health check — responds with PONG
FLUSHALL Deletes all keys in the current database (dangerous!)
INFO Returns server stats (upcoming)
QUIT Closes the client connection gracefully
TREE Displays the current tree structure of the key value store

Getting Started

Prerequisites

  • GCC or Clang compiler
  • Make
  • Linux/macOS (Windows is not officially supported)

Build Instructions

  1. Clone the repository:
    git clone https://github.com/mradulnatani/cacheieee.git
  2. Navigate into the project directory:
    cd cacheieee
  3. Build the project using make:
    make

Running the Server

To start the cacheieee server, simply run the following command:

./cacheieee

This will start the server on the default port 12049.


Connecting to the Server

You can use tools like telnet, netcat (nc), or even your own client to connect to the server:

nc localhost 12049

Once connected, you can issue the supported commands directly:

SET "name" "cacheieee"
GET name
SETEX "tempkey" 10 "hello"
TTL tempkey

Future Roadmap

Here are some features planned for future releases:

  • Snapshot-based persistence (SAVE, LOAD)
  • Eviction policies (LRU, LFU, etc.)
  • Pub/Sub system
  • Clustering and replication
  • Role-based authentication
  • Admin dashboard (via WebSocket + React?)
  • Proper algorithm for LRU and other related stuff

Contributing

Contributions, bug reports, and feature requests are welcome! Please feel free to fork the repository and submit a pull request.


License

MIT License


Acknowledgements

  • Redis and CodeCrafters for the idea and inspiration
  • Linux man pages for socket programming guidance
  • C programming GOAT Dr. Jonas Brich

Contact

Made by Mradul
Project port: 12049 | Protocol: TCP

CacheMe if you can

About

cacheieee is a lightweight, high-performance in-memory database and Cache server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors