🔴 Redis Advanced

What are Redis Functions (replacing Lua scripts in Redis 7+)?

Answer

Redis Functions, introduced in Redis 7.0, replace the EVAL-based Lua scripting model with a more robust, library-oriented approach. With EVAL, scripts are loaded and executed per-request, requiring the script body or its SHA to be sent each time. Functions are persistent: you upload a named library with FUNCTION LOAD, and the functions persist across restarts (stored in the RDB/AOF). You call them with FCALL function_name numkeys keys args. Functions support multiple entry points in one library, versioning, and metadata. They currently support Lua (the default engine) with a planned JavaScript engine. The key advantages over EVAL: functions are first-class entities with names and documentation, they survive restart without re-uploading, and they integrate with RDB/AOF persistence. Redis encourages migration from EVAL-based scripts to Functions for all production use cases.