In the StackExchange.Redis docs for scripting, it says a LoadedLuaScript can be used to avoid retransmitting the Lua script to redis each time it is evaluated. It then gives an example where the script is loaded into the server. I assume this shouldn't be done everytime you call the script, so where should the scripts be loaded?
Scripts are not persitent if redis server is restarted, so how should this be handled? Should they be loaded in ConnectionRestored event of the ConnectionMultiplexer? Presumably you would need to store them in a ConcurrentDictionary?
SCRIPT LOADcommand. This command returns sha1 hash, so this hash can be used with thEVALSHAcommand to call this script. In fact this script can be loaded by any one and your application can just use this hash.The script is guaranteed to stay in the script cache forever. Basic logic is just use EVALSHA and in case ofNOSCRIPTerror call SCRIPT LOAD and try again