Didn't spend a penny on EngineerPro's course. Worshipped the almighty camel π« instead.
jaldis is a Redis-compatible key-value store implemented in OCaml.
Demonstration video: https://www.youtube.com/watch?v=M3a44Lh2qUo
Performance benchmarks using redis-benchmark against jaldis server (in Release mode):
- Hardware: Intel Core i5-1135G7
- OS: Linux 6.18.7-arch1-1
- OCaml: 5.3.0
- Network: localhost
- Test Parameters: 1,000,000
SET/GEToperations, 100 concurrent connections
# Standard benchmark
redis-benchmark -h 127.0.0.1 -p 6969 -n 1000000 -c 100 -t set,get --csv
# Pipelined benchmark (16 commands per pipeline)
redis-benchmark -h 127.0.0.1 -p 6969 -n 1000000 -c 100 -t set,get -P 16 --csv"test","rps","avg_latency_ms","min_latency_ms","p50_latency_ms","p95_latency_ms","p99_latency_ms","max_latency_ms"
"SET","108026.36","0.851","0.224","0.879","1.247","1.551","14.343"
"GET","107411.38","0.853","0.216","0.879","1.295","1.655","13.455"
"test","rps","avg_latency_ms","min_latency_ms","p50_latency_ms","p95_latency_ms","p99_latency_ms","max_latency_ms"
"SET","244977.97","6.393","1.848","6.327","7.711","9.055","21.519"
"GET","296033.16","5.254","1.256","5.183","6.591","7.831","19.903"
- 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-asyncgit clone https://github.com/jalsol/jaldis.git
cd jaldis
dune build
dune build --release # Release mode# 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
dune testdune fmtjaldis/
βββ 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.