Skip to content

Commit

Permalink
Add new INFO evicted_scripts field and eval scripts eviction
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-binbin committed Mar 13, 2024
1 parent 6c10647 commit c12998f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions commands/eval.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ to ensure the correct execution of scripts, both in standalone and clustered dep
The script **should only** access keys whose names are given as input arguments.
Scripts **should never** access keys with programmatically-generated names or based on the contents of data structures stored in the database.

**Important:**
in some cases, users will abuse lua eval.
Each `EVAL` call generates a new lua script, which is added to the lua interpreter and cached to redis-server, consuming a large amount of memory over time.
Since `EVAL` is mostly the one that abuses the lua cache, and these won't have pipeline issues (i.e. the script won't disappear unexpectedly, and cause errors like it would with `SCRIPT LOAD` and `EVALSHA`), we implement a plain FIFO LRU eviction only for these (not for scripts loaded with `SCRIPT LOAD`).
Starting from Redis 8.0, `EVAL` SCRIPTS will maintain an LRU list of length 500, when the number exceeds the limit, the oldest `EVAL` script will be evicted.
The number of evicted scripts can be viewed through `INFO`'s `evicted_scripts`.

Please refer to the [Redis Programmability](/topics/programmability) and [Introduction to Eval Scripts](/topics/eval-intro) for more information about Lua scripts.

@examples
Expand Down
1 change: 1 addition & 0 deletions commands/info.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ Here is the meaning of all fields in the **stats** section:
* `expire_cycle_cpu_milliseconds`: The cumulative amount of time spent on active expiry cycles
* `evicted_keys`: Number of evicted keys due to `maxmemory` limit
* `evicted_clients`: Number of evicted clients due to `maxmemory-clients` limit. Added in Redis 7.0.
* `evicted_scripts`: Number of evicted EVAL scripts due to LRU policy, see `EVAL` for more details. Added in Redis 8.0.
* `total_eviction_exceeded_time`: Total time `used_memory` was greater than `maxmemory` since server startup, in milliseconds
* `current_eviction_exceeded_time`: The time passed since `used_memory` last rose above `maxmemory`, in milliseconds
* `keyspace_hits`: Number of successful lookup of keys in the main dictionary
Expand Down

0 comments on commit c12998f

Please sign in to comment.