Repository navigation
BoltCache 2.0.0
Use 2.0.1: it fixes
go install(module pathgithub.com/wutlu/boltcache/v2).
BoltCache 2.0 is a ground-up rework of the engine, the network layer and the tooling. It is now a real Redis-compatible server: redis-cli, redis-benchmark, go-redis and other clients work against it, with real Lua scripting, transactions, eviction and crash-safe persistence. It is also about 2x faster than 1.0 and outperforms Redis 8.4 on a multi-core machine in redis-benchmark (see the README for numbers and methodology).
Highlights
- Redis compatibility: 120 commands over RESP2, up from
PING/SET/GET. Strings with allSEToptions, keys/TTL (EXPIRENX/XX/GT/LT,SCANwith MATCH/COUNT/TYPE), lists, sets, hashes, pub/sub with patterns,MULTI/EXEC/WATCH, Lua,INFO,CONFIG GET,CLIENT,COMMAND,HELLOand more. - Real Lua scripting (gopher-lua) replaces the line-based imitation:
EVAL,EVALSHA,EVAL_RO,SCRIPT LOAD/EXISTS/FLUSH,redis.call/redis.pcallwith Redis type conversions. Scripts are atomic, sandboxed and time-limited. - Atomicity everywhere: every command runs under its key's shard lock; multi-key commands, transactions and scripts lock all their keys in a fixed order, so they're atomic and can't deadlock.
- Eviction and limits:
cache.max_memoryandcache.max_keysare now enforced withlru,lfu,random,ttlor the newnoevictionpolicy. - Crash-safe, typed persistence: snapshots keep value types and binary data, are written atomically (temp file + fsync + rename), can be gzipped and are skipped when nothing changed. 1.x snapshots are converted automatically.
- Security: token authentication is enforced on REST, RESP and TCP; CORS allow-list (also for WebSockets) with CSRF protection, per-IP rate limiting, request size limits (strict ones for unauthenticated clients), HTTPS for the REST API, constant-time token checks, sandboxed Lua.
- Observability: Prometheus
/metrics,/healthand/ready, structured logging withlog/slog(text/JSON), optional pprof. - Distribution: prebuilt binaries for Linux, macOS, Windows and FreeBSD (amd64/arm64), multi-arch distroless images on
ghcr.io/wutlu/boltcache,go install github.com/wutlu/boltcache@latest.
Added
- RESP listener (
server.resp, port 6382) with incremental, zero-copy parsing: pipelining, partial reads and inline commands are handled correctly. The TCP port (6380) auto-detects RESP, so Redis clients work there too. - REST endpoints:
GET /list/{key},DELETE /set/{key}/{member},GET /hash/{key},DELETE /hash/{key}/{field},GET /cache/{key}/ttl,GET /keys(paginated),POST /command(run any command),/health,/ready,/metrics.GET /cache/{key}returns lists, sets and hashes too. - Real token management:
POST/GET/DELETE /auth/tokenscreate, list (masked, with usage statistics) and revoke runtime tokens valid for every protocol. ${VAR}/${VAR:-default}environment expansion in configuration files andBOLTCACHE_CONFIG.boltcache config show,boltcache version,boltcache config generate --force;config validatereports every problem at once.boltcache client benchmark: parallel, pipelined load generator with p50/p99 latency.client interactiveis now a RESP client similar toredis-cli, andclient testruns a feature check.features.lua_timeout,cache.default_ttl/max_ttlfor the REST API,persistence.compression,security.rate_limitandsecurity.tlsnow take effect.- Web client: "run any command" box, token stored in the browser, works on any host/port.
- CI on Linux and macOS with the race detector, fuzzing and golangci-lint; GoReleaser and Docker release automation; Dependabot.
Fixed
- The Redis-compatible port hung on any command other than
PING,SETandGET(no reply was sent), which also maderedis-benchmarkhang at startup. - Commands split across TCP packets were silently dropped, and only the first three arguments of a command were parsed.
- On the high-performance text port, any command starting with
sorgwas treated asSET/GET(e.g.SADD x ystored a value). - Authentication was configured but never enforced: the middleware was commented out, so tokens in
config-dev.yamlprotected nothing. - Data races between hash/set/list writes, reads and snapshots could crash the server with
concurrent map read and map write. - After a restart, values written over RESP came back base64-encoded, and writing to a restored hash/set/list wiped its previous contents.
- Persistence wrote the snapshot in place, so a crash during a save could leave a truncated file.
- Pub/sub: dead subscribers were never removed, one slow subscriber blocked publishers, and concurrent writes to a WebSocket could panic the server.
POST /evalpanicked when Lua scripting was disabled;ParseMemorySize("1")panicked.- The web client was vulnerable to XSS through cached values and pub/sub messages, and was hard-wired to
localhost:8090. KEYS/PSUBSCRIBEglob matching could take exponential time on hostile patterns.config validateignored--config;config generateoverwrote existing files;SIGTERMdidn't stop the HTTP server gracefully.
Changed
- Breaking: the Go module path is
github.com/wutlu/boltcacheand Go 1.26 or newer is required to build. - Breaking: authentication is enforced when
security.auth.enabledis true (see above). - Breaking: writing a different type to an existing key returns
WRONGTYPEinstead of silently replacing it, and replies follow Redis (e.g.HSETreturns the number of new fields,DELthe number of deleted keys). - Breaking: the separate gnet text listener on
tcp.port + 1(6381) was removed; port 6380 now runs on gnet and serves both protocols. - Breaking: the
clustercommand was removed. It started an isolated node and never replicated data; replication is on the roadmap. gorilla/muxwas replaced with the standard library router;gopkg.in/yaml.v3(archived) withgo.yaml.in/yaml/v3. All dependencies were updated.- Defaults:
server.modeisboth, the REST port is 8090 everywhere,eviction_thresholdis 1.0, snapshot compression is off, andcors_originsis empty (same origin only) instead of*, so web pages you visit can't use a local BoltCache. Non-GET requests from origins that aren't allowed get403. - The Docker image is distroless, runs as non-root, is multi-arch and is configured through
BOLTCACHE_*environment variables;docker-compose.ymlwas fixed. - Swagger UI assets are pinned to a fixed version; the OpenAPI document covers every endpoint and declares the auth schemes.
Install
docker run -d -p 6382:6382 -p 8090:8090 -v boltcache-data:/data ghcr.io/wutlu/boltcache:2.0.0
go install github.com/wutlu/boltcache/v2@latest # from 2.0.1Or download a binary below. Upgrading from 1.x? Read the Upgrading from 1.x section of the README first: authentication is now enforced and a few behaviours changed.