abhishek

Menu

Close

CacheIt - High-performance In-Memory Caching Server
A Redis-like in-memory data store implemented in C++ with epoll and multithreading
C++
Networking
Data Structures
High Performance
Systems Programming
Multithreading
Linux
Image of CacheIt - High-performance In-Memory Caching Server

#Overview

CacheIt is a high-performance, in-memory caching server built in C++ with a focus on performance and efficiency. It implements core data structures and algorithms to provide Redis-like functionality with low-latency operations.

#Key Features

  • High Performance: Achieves 0.21ms average latency with 99.99% success rate under load
  • Multi-threaded: Utilizes modern C++ threading for concurrent request handling
  • Non-blocking I/O: Implements epoll for efficient event-driven architecture
  • Multiple Data Structures:
    • Strings (key-value pairs)
    • Linked Lists
    • Sets
    • Hashes
    • Sorted Sets
    • Bitmaps
  • Memory Management: Implements LRU/LFU eviction policies
  • Logging: Built-in logging with different severity levels

#Technical Highlights

  • Core Data Structures:

    • Custom HashMap implementation
    • Thread-safe Set and Sorted Set implementations
    • Efficient memory management with smart pointers
    • LRU/LFU eviction policies
  • Networking:

    • TCP server implementation
    • Non-blocking I/O with epoll
    • Connection pooling
    • Command pipelining support

#Performance Metrics

  • Average Latency: 0.21ms
  • Success Rate: 99.99%
  • Concurrent Connections: Tested with 10,000+ concurrent clients
  • Throughput: Handles 100,000+ operations per second

#Getting Started

#Prerequisites

  • C++17 or later
  • CMake 3.10+
  • Linux (for epoll support)

#Building from Source

git clone https://github.com/abhiphile/cacheit.git
cd cacheit
mkdir build && cd build
cmake ..
make

#Running the Server

./cacheit/src/server

#Using the Client

./cacheit/src/client

#Example Usage

# String operations
> set greeting "Hello, World!"
REPLY: OK
> get greeting
REPLY: Hello, World!
 
# List operations
> lpush numbers 1 2 3 4 5
REPLY: pushed 5 values to numbers
> lrange numbers 0 -1
REPLY: 1 2 3 4 5
 
# Set operations
> sadd unique 1 2 3 3 4 4 5
REPLY: added 5
> smembers unique
REPLY: 1 2 3 4 5
 
# Hash operations
> hset user:1 name "John Doe" age 30
REPLY: OK
> hget user:1 name
REPLY: John Doe

#Testing

Run the comprehensive test suite:

python3 test/run_all_tests.py

Individual test files are also available for specific data structures:

python3 test/test_string.py
python3 test/test_linkedlist.py
python3 test/test_set.py
python3 test/test_hash.py
python3 test/test_zset.py
python3 test/test_bitmap.py

#Docker Support

Pull and run the Docker image:

docker pull abhishek194/cacheit
docker run -p 8080:8080 abhishek194/cacheit

#Project Structure

cacheit/
├── include/
│   ├── command.hpp
│   ├── conn.hpp
│   ├── datastructures/
│   │   ├── linked_list.hpp
│   │   └── hashmap.hpp
│   ├── epoll_manager.hpp
│   ├── logger.hpp
│   ├── server.hpp
│   └── utils.hpp
└── src/
    ├── client.cpp
    ├── command.cpp
    ├── conn.cpp
    ├── datastructures/
    │   ├── linked_list.cpp
    │   └── hashmap.cpp
    ├── epoll_manager.cpp
    ├── logger.cpp
    ├── server.cpp
    └── utils.cpp

#License

This project is licensed under the MIT License. See the LICENSE file for details.