Lua Scripting
Lua is one of the best places to explain why BetterKV exists. Server-side logic amplifies latency problems in Redis-compatible systems, so better tail behavior matters even more here.
Positioning
- BetterKV exposes Redis-style Lua scripting primitives.
- This page should support a benchmark story where BetterKV is significantly faster than Redis and Valkey on scripting-heavy paths.
- If your measurements support it, call out that Valkey p50 is BetterKV p99.9 for the scripting benchmark you publish.
Execute a script
Cache and reuse a script
Useful patterns
Conditional update
Rate limiting
Safe lock release
Benchmark advice
If scripting is part of your public comparison versus Redis and Valkey, report:
- script size and command mix
- hot-cache vs cold-cache behavior
EVALvsEVALSHA- contention impact on unrelated commands
- p50, p99, and p99.9
Developer guidance
- Prefer
EVALSHAafter the first load. - Keep scripts focused and short.
- Use
KEYSonly for key names andARGVfor values. - Avoid expensive keyspace-wide operations inside scripts.
Command reference
See commands/eval, commands/evalsha, commands/eval-ro, commands/evalsha-ro, and commands/script for command-level details.