Expand description
kevy-lua — Redis EVAL / EVALSHA / SCRIPT surface backed by luna-core.
kevy’s script-host layer. Thin “cement” crate (per the
stone-cement-stone model) — it carries no algorithmic content, only
the bridge between kevy-rt’s command dispatch path, kevy-resp’s
wire codec, and luna-core’s sandboxed Vm.
Design lock-in:
- Default Lua 5.1 — preserves the Redis Lua ecosystem (BullMQ, Redlock, rate limiters, anything copied from Redis docs).
- Per-script dialect opt-in via
#!lua version=N— scripts opt into 5.2 / 5.3 / 5.4 / 5.5 with a single shebang line. SHA1 cache key is the raw script bytes, so EVALSHA is version-aware for free. - VM per-shard, per-dialect, lazily spawned — first EVAL hitting a dialect on a shard constructs the VM; reused afterwards. Idle RSS scales with dialects actually used.
- Atomic execution — entering EVAL pauses other dispatch on that shard until the script returns. Matches Redis semantics.
Bridge holds a per-dialect Vm pool (lazy-spawned); eval() runs
the script under the sandbox and marshals the first returned
Value into a RESP reply. Shebang parsing, SHA1 cache, EVALSHA,
SCRIPT LOAD/EXISTS/FLUSH, and the redis.call host plumbing all
live here.
Modules§
- sha1
- SHA-1 digest helpers. Exposed because the operator-side wire layer (kevy-rt’s SCRIPT LOAD / EVALSHA codec) needs to convert between the 20-byte digest used as a cache key and the 40-char ASCII hex Redis uses on the wire. Hand-rolled SHA-1 (RFC 3174 / FIPS 180-1).
Structs§
- Bridge
- kevy-lua per-shard bridge. One
Bridgelives in each shard’s runtime; it owns the per-dialect VM pool, the SHA1 cache, and the kevy-side dispatch callback thatredis.callinvokes.
Enums§
- Flush
Mode - SCRIPT FLUSH mode (Redis 6.2+ semantics).
- LuaVersion
- Re-export so callers can name the dialect without depending on
luna-core directly.
Lua dialect the VM emulates. Drives lexer, parser, and runtime feature
gating.
Lua55is the primary; the others are compat modes;MacroLua(v1.3 Phase ML) is an additive dialect built on top of the 5.4 base.
Type Aliases§
- Reply
- A wire-level reply: just the encoded RESP bytes.
- Script
Sha1 - A SHA1 hash of a script’s source bytes. Used as the EVALSHA cache
key. Includes any
#!lua version=Nshebang in the input, so a 5.1 script and the same script with a 5.3 shebang have distinct SHA1s and never collide in the cache.