Skip to content

Commit

Permalink
Address misleading documentation
Browse files Browse the repository at this point in the history
Remove references that mention SHA-1 hashes being passed when evaluating server loaded Lua scripts.
The current implementation passes the script itself instead of the hash, generated when the script was initially loaded, due to resiliency concerns.
  • Loading branch information
SonnyRR committed Apr 25, 2023
1 parent 571d832 commit cf917c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/Scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ Any object that exposes field or property members with the same name as @-prefix
- RedisKey
- RedisValue

StackExchange.Redis handles Lua script caching internally. It automatically transmits the Lua script to redis on the first call to 'ScriptEvaluate'. For further calls of the same script only the hash with [`EVALSHA`](https://redis.io/commands/evalsha) is used.
StackExchange.Redis handles Lua script caching internally. It automatically transmits the Lua script to redis on the first call to 'ScriptEvaluate'. For further calls of the same script [`EVAL`](https://redis.io/commands/eval) is used instead of [`EVALSHA`](https://redis.io/commands/evalsha), due to resiliency concerns.

For more control of the Lua script transmission to redis, `LuaScript` objects can be converted into `LoadedLuaScript`s via `LuaScript.Load(IServer)`.
`LoadedLuaScripts` are evaluated with the [`EVALSHA`](https://redis.io/commands/evalsha), and referred to by hash.
`LoadedLuaScripts` are evaluated with the [`EVAL`](https://redis.io/commands/eval) command instead of [`EVALSHA`](https://redis.io/commands/evalsha), due to resiliency concerns.

An example use of `LoadedLuaScript`:

Expand Down
10 changes: 5 additions & 5 deletions src/StackExchange.Redis/LuaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public sealed class LoadedLuaScript

/// <summary>
/// <para>The SHA1 hash of ExecutableScript.</para>
/// <para>This is sent to Redis instead of ExecutableScript during Evaluate and EvaluateAsync calls.</para>
/// <para>This is not sent to Redis, instead ExecutableScript is used during Evaluate and EvaluateAsync calls.</para>
/// </summary>
/// <remarks>Be aware that using hash directly is not resilient to Redis server restarts.</remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
Expand All @@ -257,8 +257,8 @@ internal LoadedLuaScript(LuaScript original, byte[] hash)
/// <summary>
/// <para>Evaluates this LoadedLuaScript against the given database, extracting parameters for the passed in object if any.</para>
/// <para>
/// This method sends the SHA1 hash of the ExecutableScript instead of the script itself.
/// If the script has not been loaded into the passed Redis instance, it will fail.
/// This method evaluates the script itself and does not send the SHA-1 hash, generated by the server when loaded initially, in order to execute it.
/// If the script has not been loaded into the passed Redis instance, it will not fail.
/// </para>
/// </summary>
/// <param name="db">The redis database to evaluate against.</param>
Expand All @@ -275,8 +275,8 @@ public RedisResult Evaluate(IDatabase db, object? ps = null, RedisKey? withKeyPr
/// <summary>
/// <para>Evaluates this LoadedLuaScript against the given database, extracting parameters for the passed in object if any.</para>
/// <para>
/// This method sends the SHA1 hash of the ExecutableScript instead of the script itself.
/// If the script has not been loaded into the passed Redis instance, it will fail.
/// This method evaluates the script itself and does not send the SHA-1 hash, generated by the server when loaded initially, in order to execute it.
/// If the script has not been loaded into the passed Redis instance, it will not fail.
/// </para>
/// </summary>
/// <param name="db">The redis database to evaluate against.</param>
Expand Down

0 comments on commit cf917c8

Please sign in to comment.