0Pricing
Lua Academy · Lesson

SCRIPT LOAD and EVALSHA

Load scripts with SCRIPT LOAD and execute by SHA1 for efficiency.

The Problem with EVAL

EVAL sends the full script text on every call. For frequently executed scripts this wastes bandwidth. SCRIPT LOAD + EVALSHA solve this by loading once and calling by SHA1 hash.

SCRIPT LOAD

SCRIPT LOAD script compiles the script, caches it in Redis, and returns its SHA1 hash. The script stays cached until the server restarts or SCRIPT FLUSH is called.

# Redis CLI:
SCRIPT LOAD "return redis.call('GET', KEYS[1])"
# Returns: "abc123...sha1hash..."

All lessons in this course

  1. EVAL and Redis Lua Environment
  2. Atomic Operations and Transactions
  3. Rate Limiting with Lua
  4. SCRIPT LOAD and EVALSHA
← Back to Lua Academy