A fast, Redis-compatible in-memory cache server β written in Rust.
Drop-in for Redis (RESP2/3 wire protocol): point your existing Redis client at inmem and it just works. No Redis required β inmem is the server.
- β‘ Fast. In a two-machine x86 benchmark (memtier, mixed GET/SET) inmem is the fastest of every system tested β ahead of Redis, Valkey, KeyDB, Memcached, Dragonfly, and matching/beating Garnet. See Benchmarks (with honest caveats).
- π Drop-in for Redis. Speaks RESP2 & RESP3 β use your existing Redis client and tools
(
redis-cli,redis-benchmark, redis-py, ioredis, go-redis, Lettuce, β¦). Just change the port. - π§± Real data types. Strings, lists, hashes, sets, sorted sets β with
WRONGTYPEsemantics. - β±οΈ TTL & eviction. Per-key expiry plus a
maxmemorybudget with S3-FIFO eviction. - πΎ Durable. Append-only file (AOF) and snapshots, replayed on startup.
- π Replication. Async primary β read-only replicas (
--replicaof). - π Secure-ish. Password auth (
--requirepass) and optional TLS (--features tls). - π¦ Safe & portable. Pure Rust; runs on Linux, macOS, and Windows (x86_64 + arm64).
- π¦ Embeddable. Use the
inmem-corecrate as an in-process cache (no server, no network).
Status: v0.1.x β early but complete and tested (44 tests incl. fuzz + concurrency + TCP e2e). API and wire compatibility are stable for the supported commands.
# Docker β works on Linux, macOS, and Windows (Docker Desktop / WSL2)
docker run -d --name inmem -p 6380:6380 ghcr.io/ashishlathkar77/inmem:latest
# Verify with the standard Redis CLI
redis-cli -p 6380 ping # β PONG
redis-cli -p 6380 set hi there
redis-cli -p 6380 get hi # β "there"That's it β inmem is now serving on port 6380, speaking the Redis protocol.
| Method | Command | Platforms |
|---|---|---|
| Docker | docker run -d -p 6380:6380 ghcr.io/ashishlathkar77/inmem:latest |
Linux Β· macOS Β· Windows |
| Script (prebuilt binary) | curl -fsSL https://raw.githubusercontent.com/Ashishlathkar77/In-mem0/main/install.sh | sh |
Linux Β· macOS |
| Windows binary | Download inmemd-windows-x86_64.exe from Releases, run inmemd.exe --port 6380 |
Windows |
| Cargo | cargo install inmem-server (once published) / or from source below |
any |
| Source | git clone β¦ && cargo build --release && ./target/release/inmemd --port 6380 |
any |
Prebuilt binaries are published for linux-x86_64, linux-aarch64, macos-x86_64, macos-aarch64, windows-x86_64 on every release.
services:
inmem:
image: ghcr.io/ashishlathkar77/inmem:latest
ports: ["6380:6380"]
command: ["--bind", "0.0.0.0", "--port", "6380", "--maxmemory", "512mb"]Use any Redis client β same code you'd write for Redis, just the address. (inmem does not require Redis to be installed; it replaces it.)
Python (pip install redis)
import redis
r = redis.Redis(host="localhost", port=6380)
r.set("user:1", "alice")
print(r.get("user:1")) # b'alice'
r.lpush("queue", "a", "b") # lists
r.hset("profile", "name", "alice") # hashes
r.sadd("tags", "x", "y") # sets
r.zadd("board", {"alice": 10}) # sorted sets
r.expire("user:1", 60) # TTLNode.js (npm i ioredis)
import Redis from "ioredis";
const r = new Redis(6380, "localhost");
await r.set("k", "v");
console.log(await r.get("k"));
await r.rpush("list", "a", "b");
await r.hset("h", "f", "v");Go (go get github.com/redis/go-redis/v9)
rdb := redis.NewClient(&redis.Options{Addr: "localhost:6380"})
rdb.Set(ctx, "k", "v", 0)
val, _ := rdb.Get(ctx, "k").Result()Embedded (Rust, no server)
# Cargo.toml
inmem-core = "0.0"use inmem_core::{Store, SetOptions};
let cache = Store::new(/*shards*/ 256, /*maxmemory bytes*/ 0);
cache.set(b"k", b"v", SetOptions::default());
assert_eq!(cache.get(b"k").unwrap().as_deref(), Some(&b"v"[..]));| Group | Commands |
|---|---|
| Connection | PING ECHO HELLO AUTH SELECT QUIT COMMAND CONFIG GET CLIENT INFO DBSIZE FLUSHALL/FLUSHDB |
| Strings | SET (EX/PX/EXAT/PXAT/NX/XX/KEEPTTL/GET) GET GETSET SETNX SETEX PSETEX MSET MGET APPEND STRLEN INCR DECR INCRBY DECRBY |
| Lists | LPUSH RPUSH LPOP RPOP LLEN LRANGE |
| Hashes | HSET HMSET HGET HMGET HDEL HLEN HEXISTS HGETALL HKEYS HVALS |
| Sets | SADD SREM SISMEMBER SCARD SMEMBERS |
| Sorted sets | ZADD ZSCORE ZREM ZCARD ZRANGE (WITHSCORES) |
| Keyspace | DEL UNLINK EXISTS TYPE EXPIRE PEXPIRE EXPIREAT PEXPIREAT PERSIST TTL PTTL KEYS SCAN |
| Persistence | SAVE BGSAVE |
inmemd [OPTIONS]
--port <N> listen port (default 6380)
--bind <ADDR> bind address (default 127.0.0.1; use 0.0.0.0 in containers)
--shards <N> store partitions for concurrency (default 512)
--maxmemory <SIZE> memory budget, e.g. 512mb, 2gb (default: unbounded)
--appendonly <yes|no> enable AOF persistence (default no)
--requirepass <PASS> require AUTH with this password
--replicaof <H:P> run as a read-only replica of a primary
--masterauth <PASS> password to authenticate to the primary
--tls-cert <FILE> PEM cert chain to enable TLS (build with --features tls)
--tls-key <FILE> PEM private key for TLS
--dir <PATH> directory for persistence files (default .)
Replication example:
inmemd --port 6380 # primary
inmemd --port 6381 --replicaof 127.0.0.1:6380 # read-only replica, auto-syncsTwo-machine AWS c7i.4xlarge (16 vCPU x86) rig β dedicated load generator, server over the private
network, memtier_benchmark, mixed GET/SET, 64-byte values. 3-run medians (ops/sec):
| System | -P 1 |
-P 16 |
-P 64 |
|---|---|---|---|
| inmem | 1.18M | 11.6M | 15.0M |
| garnet | 1.18M | 9.0M | 13.8M |
| dragonfly | 1.07M | 3.74M | 5.73M |
| redis | 0.24M | 1.52M | 2.16M |
| valkey | 0.21M | 1.28M | 1.78M |
| keydb | 0.36M | 1.34M | 1.45M |
| memcached | 1.13M | 1.38M | 1.35M |
Honest scope. "Fastest" means among sockets/RESP cache servers in this configuration. It is not a claim against in-process caches or kernel-bypass/RDMA/FPGA key-value stores, which are a different and faster category. There is ~Β±15% run-to-run variance, and the best inmem runtime is regime-dependent (portable peaks at
-P 16, the Linux io_uring build at-P 64). Reproduce withscripts/bench-all.sh. Full methodology + caveats: docs/BENCHMARKS.md.
inmem's design is grounded in a fact-checked survey of the fastest systems and the relevant research, and validated by profiling. Key choices:
- Sharded store, 512 partitions, lock per shard (
parking_lot) β low contention at high concurrency. The eviction policy is bypassed entirely when unbounded (maxmemory=0). - Flat open-addressing hash index with tombstone-free backward-shift deletion.
- S3-FIFO eviction (SOSP'23) β beats LRU/ARC on miss ratio and throughput.
- Zero-copy hot path β borrowed
GET, alloc-freeSET/INCR, pipelined responses coalesced into one write;mimallocallocator. - Optional Linux io_uring thread-per-core runtime (
--features io-uring).
Deep dives: Architecture (ADR-001) Β· io_uring runtime (ADR-002) Β· Research notes Β· Benchmarks.
git clone https://github.com/Ashishlathkar77/In-mem0.git
cd In-mem0
cargo build --release # portable server β target/release/inmemd
cargo test # 44 tests
cargo build --release --features tls # + TLS
cargo build --release --features io-uring # + Linux io_uring runtimeRequires Rust 1.96+ (pinned in rust-toolchain.toml).
Project layout
crates/core inmem-core embeddable cache: hash index, S3-FIFO eviction, sharded store
crates/proto inmem-proto RESP2/3 parser + encoder
crates/server inmem-server the inmemd server, command dispatch, persistence, replication, TLS
docs/ architecture decision records, research, benchmarks
scripts/ benchmark + provisioning helpers
- Strings/lists/hashes/sets/sorted-sets, TTL, eviction, persistence, AUTH, replication, TLS
- Cross-platform (Linux/macOS/Windows), Docker image, prebuilt binaries
- io_uring single-owner shards (lock-free) on Linux
- More commands (
LINDEX,ZRANGEBYSCORE,GETDEL, β¦) and data-type coverage - Clustering, pub/sub, Redis-compatible
PSYNC -
cargo installvia crates.io, Homebrew tap
Contributions are welcome β see CONTRIBUTING.md (correctness first, tests required, hot path stays allocation-free). Please also read the Code of Conduct. Security reports: SECURITY.md.