Nitro is a highly concurrent, in-memory key-value database written from scratch in Go, inspired by Redis. It prioritizes performance through Goroutines and thread-safe concurrent operations, while ensuring reliability through Append-Only File (AOF) persistence and crash recovery mechanisms.
Note
Nitro is currently in the early stages of development. Features and APIs may change as the project evolves.
- High Performance: Built with Goroutines and RWMutexes for highly concurrent, thread-safe operations. Handles multiple concurrent clients efficiently with minimal latency.
- Eviction Engine: Implements LRU (Least Recently Used) eviction with mathematical tracking to manage memory and prevent unbounded growth.
- Crash Recovery: AOF (Append-Only File) persistence logs all write operations, enabling complete data recovery on restart with zero data loss.
- RESP Compatible: Fully implements the Redis Serialization Protocol (RESP), allowing seamless integration with
redis-cliand other Redis tools out-of-the-box. - Multiple Data Structures: Supports Strings, Hashes, Sets, and Lists—covering the core data types needed for modern applications.
Commands are issued via redis-cli on port 7070. The following commands are fully supported:
# Set a key-value pair
redis-cli -p 7070 SET mykey "Hello"
# Output: OK
# Get a value by key
redis-cli -p 7070 GET mykey
# Output: "Hello"
# Echo a message
redis-cli -p 7070 ECHO "Nitro DB"
# Output: "Nitro DB"# Set a hash field
redis-cli -p 7070 HSET user:1 name "Alice" email "alice@example.com"
# Output: OK
# Get a hash field
redis-cli -p 7070 HGET user:1 name
# Output: "Alice"# Add members to a set
redis-cli -p 7070 SADD myset member1 member2 member3
# Output: 3
# Get all set members
redis-cli -p 7070 SMEMBERS myset
# Output: (array of members)
# Check set membership
redis-cli -p 7070 SISMEMBER myset member1
# Output: 1 (true)
# Remove members from a set
redis-cli -p 7070 SREM myset member1
# Output: 1# Push values to the head of a list
redis-cli -p 7070 LPUSH mylist "world"
redis-cli -p 7070 LPUSH mylist "hello"
# Output: 2
# Push values to the tail of a list
redis-cli -p 7070 RPUSH mylist "!"
# Output: 3
# Get a range of list elements
redis-cli -p 7070 LRANGE mylist 0 -1
# Output: ["hello", "world", "!"]# Set key expiration (in seconds)
redis-cli -p 7070 EXPIRE mykey 3600
# Output: 1 (success)
# Get remaining time-to-live (in seconds)
redis-cli -p 7070 TTL mykey
# Output: 3599
# Health check
redis-cli -p 7070 PING
# Output: PONG- Go 1.22 or higher
- Basic understanding of Redis protocol and concurrent programming in Go
# Clone the repository
git clone https://github.com/RudraPrasad001/Nitro.git
cd Nitro
# Install dependencies (go mod automatically handles this)
go mod download
# Run the application
go run ./cmd/nitro
# Run the extensive test suite
go test -v -count=1 ./internal/storeThe test suite validates all core store operations, including concurrent reads/writes, LRU eviction, TTL expiration, and data structure integrity.
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Commit your changes with clear messages (
git commit -m 'Add my feature') - Push to your fork (
git push origin feature/my-feature) - Open a Pull Request
Please ensure all tests pass and follow Go best practices (gofmt, golint).
This project is licensed under the MIT License. See the LICENSE file for details.
Built with performance, reliability, and simplicity in mind.