jaldis is a Redis-compatible key-value store implemented in OCaml.
Demonstration video: https://www.youtube.com/watch?v=M3a44Lh2qUo
- Strings - Store and retrieve text values
- Lists - Ordered collections with push/pop operations
- Sets - Unordered collections of unique elements
SET/GET
- Basic key-value operationsDEL
- Delete keysKEYS
- List all keysFLUSHDB
- Clear all data
LPUSH/RPUSH
- Push elements to front/backLPOP/RPOP
- Pop elements from front/back (with optional count)LLEN
- Get list lengthLRANGE
- Get elements in range
SADD
- Add elements to setSREM
- Remove elements from setSCARD
- Get set sizeSMEMBERS
- Get all set membersSINTER
- Set intersectionSISMEMBER
- Check membership
EXPIRE
- Set key expiration in secondsTTL
- Get time-to-live for key- Automatic cleanup - Background sweep removes expired keys
- RESP (Redis Serialization Protocol) - Full compatibility with Redis clients
- TCP server - Standard Redis port (6379) or custom port
- OCaml 5.0+
- Dune 3.17+
- OPAM package manager
opam install core async ppx_jane zarith angstrom angstrom-async
git clone https://github.com/jalsol/jaldis.git
cd jaldis
dune build
# Default port 6969
dune exec server
# Custom port
dune exec server -- -port 6379
- Storage Engine - In-memory hash tables with expiration tracking
- RESP Parser - Full Redis protocol implementation
- Command Handler - Redis-compatible command processing
- Async Server - High-performance TCP server using Jane Street's Async
- Optimized Expiration - Hybrid sweep strategy (O(1) for large datasets)
- Memory Efficient - Separate storage and expiration tracking
- Non-blocking - Asynchronous I/O for concurrent connections
- Small Tables (≤100 keys): Full scan with early termination
- Large Tables (>100 keys): Probabilistic sampling to avoid O(n) scans
- Background Cleanup - Automatic expired key removal every 100ms
Performance benchmarks using redis-benchmark
against jaldis server:
- Hardware: Intel Core i5-1135G7
- OS: Linux 5.15.0-130-generic
- OCaml: 5.3.0
- Network: localhost
- Test Parameters: 100,000
SET/GET
operations, 100 concurrent connections
# Standard benchmark
redis-benchmark -h 127.0.0.1 -p 6969 -n 100000 -c 100 -t set,get --csv
# Pipelined benchmark (16 commands per pipeline)
redis-benchmark -h 127.0.0.1 -p 6969 -n 100000 -c 100 -t set,get -P 16 --csv
dune test
dune fmt
jaldis/
├── bin/ # Server executable
├── misc/ # Utilities and test scripts
├── resp/ # RESP protocol implementation
├── server/ # Core storage and command handling
└── test/ # Unit and integration tests
Storage
- Core key-value storage with TTL supportCommands
- Redis command implementationsParser/Serializer
- RESP protocol handlingRstring/Rlist/Rset
- Data type specific operations
- ✅ Core data types (String, List, Set)
- ✅ Expiration and TTL
- ✅ RESP protocol
- ✅ Most common commands
- ✅ Redis client compatibility
- Hash data type
- Sorted sets
- Pub/Sub
- Persistence
- Clustering
- Transactions
MIT License - see LICENSE file for details.