summaryrefslogtreecommitdiffstats
path: root/iredis/data/commands/eval.md
diff options
context:
space:
mode:
Diffstat (limited to 'iredis/data/commands/eval.md')
-rw-r--r--iredis/data/commands/eval.md27
1 files changed, 24 insertions, 3 deletions
diff --git a/iredis/data/commands/eval.md b/iredis/data/commands/eval.md
index d1d0346..3618ac6 100644
--- a/iredis/data/commands/eval.md
+++ b/iredis/data/commands/eval.md
@@ -214,6 +214,27 @@ format specified above (as a Lua table with an `err` field). The script can pass
the exact error to the user by returning the error object returned by
`redis.pcall()`.
+## Running Lua under low memory conditions
+
+When the memory usage in Redis exceeds the `maxmemory` limit, the first write
+command encountered in the Lua script that uses additional memory will cause the
+script to abort (unless `redis.pcall` was used). However, one thing to caution
+here is that if the first write command does not use additional memory such as
+DEL, LREM, or SREM, etc, Redis will allow it to run and all subsequent commands
+in the Lua script will execute to completion for atomicity. If the subsequent
+writes in the script generate additional memory, the Redis memory usage can go
+over `maxmemory`.
+
+Another possible way for Lua script to cause Redis memory usage to go above
+`maxmemory` happens when the script execution starts when Redis is slightly
+below `maxmemory` so the first write command in the script is allowed. As the
+script executes, subsequent write commands continue to generate memory and
+causes the Redis server to go above `maxmemory`.
+
+In those scenarios, it is recommended to configure the `maxmemory-policy` not to
+use `noeviction`. Also Lua scripts should be short so that evictions of items
+can happen in between Lua scripts.
+
## Bandwidth and EVALSHA
The `EVAL` command forces you to send the script body again and again. Redis
@@ -619,13 +640,13 @@ the cause of bugs.
## Using Lua scripting in RESP3 mode
-Starting with Redis version 6, the server supports two differnent protocols. One
+Starting with Redis version 6, the server supports two different protocols. One
is called RESP2, and is the old protocol: all the new connections to the server
start in this mode. However clients are able to negotiate the new protocol using
the `HELLO` command: this way the connection is put in RESP3 mode. In this mode
certain commands, like for instance `HGETALL`, reply with a new data type (the
Map data type in this specific case). The RESP3 protocol is semantically more
-powerful, however most scripts are ok with using just RESP2.
+powerful, however most scripts are OK with using just RESP2.
The Lua engine always assumes to run in RESP2 mode when talking with Redis, so
whatever the connection that is invoking the `EVAL` or `EVALSHA` command is in
@@ -669,7 +690,7 @@ At this point the new conversions are available, specifically:
- Lua table with a single `map` field set to a field-value Lua table -> Redis
map reply.
- Lua table with a single `set` field set to a field-value Lua table -> Redis
- set reply, the values are discared and can be anything.
+ set reply, the values are discarded and can be anything.
- Lua table with a single `double` field set to a field-value Lua table -> Redis
double reply.
- Lua null -> Redis RESP3 new null reply (protocol `"_\r\n"`).