private StackRedis.RedisResult Eval(ScriptType scriptType, StackRedis.RedisKey redisKey, StackRedis.RedisValue[] values = null, StackRedis.CommandFlags flags = StackRedis.CommandFlags.None) { if (!this.scriptsLoaded) { lock (this.lockObject) { if (!this.scriptsLoaded) { this.LoadScripts(); this.scriptsLoaded = true; } } } StackRedis.LoadedLuaScript script; if (!this.shaScripts.TryGetValue(scriptType, out script)) { this.Logger.LogCritical("Something is wrong with the Lua scripts. Seem to be not loaded."); this.scriptsLoaded = false; throw new InvalidOperationException("Something is wrong with the Lua scripts. Seem to be not loaded."); } try { return(this.connection.Database.ScriptEvaluate(script.Hash, new[] { redisKey }, values, flags)); } catch (StackRedis.RedisServerException ex) when(ex.Message.StartsWith("NOSCRIPT", StringComparison.OrdinalIgnoreCase)) { this.Logger.LogInfo("Received NOSCRIPT from server. Reloading scripts..."); this.LoadScripts(); // retry throw; } }
private StackRedis.RedisResult Eval(ScriptType scriptType, object parameters, StackRedis.CommandFlags flags = StackRedis.CommandFlags.None) { if (!this.scriptsLoaded) { lock (this.loadScriptLock) { if (!this.scriptsLoaded) { this.LoadScripts(); this.scriptsLoaded = true; } } } StackRedis.LoadedLuaScript script; if (!this.shaScripts.TryGetValue(scriptType, out script)) { throw new InvalidOperationException("Something went wrong during loading scripts to the server."); } try { return(this.Database.ScriptEvaluate(script, parameters, flags)); } catch (StackRedis.RedisServerException ex) when(ex.Message.StartsWith("NOSCRIPT", StringComparison.OrdinalIgnoreCase)) { this.LoadScripts(); throw; } }