Esempio n. 1
0
        public override eRedisAccessError DoCommand(RedisClient redisCli)
        {
#if RedisCommandSpendTime
            m_sw.Stop();
            m_spendMillisecArr[0] = m_sw.ElapsedMilliseconds;
            m_sw.Restart();
#endif
            try
            {
                if (m_script.m_SHA == null || redisCli.HasLuaScript(m_script.m_SHA) == false)
                {
                    m_script.m_SHA = redisCli.LoadLuaScript(m_script.m_Body);
                }
                byte[][] luaArgvByteArr = new byte[m_luaArgv.Length][];
                for (int i = 0; i < m_luaArgv.Length; ++i)
                {
                    luaArgvByteArr[i] = m_luaArgv[i].ToUtf8Bytes();
                }
                m_theReturn = redisCli.EvalSha(m_script.m_SHA, 0, luaArgvByteArr);
            }
            catch (Exception ex)
            {
                m_Err = eRedisAccessError.Command_Exec_Fail;
                SvLogger.Fatal(ex, "ScriptName={2}\nScriptBody={3} -> {0}\n{1}.", ex.Message, ex.StackTrace, m_script.m_Name, m_script.m_Body);
            }

#if RedisCommandSpendTime
            m_sw.Stop();
            m_spendMillisecArr[1] = m_sw.ElapsedMilliseconds;
            m_sw.Restart();
#endif

            return(m_Err);
        }
Esempio n. 2
0
        public override eRedisAccessError DoCommand(RedisClient redisCli)
        {
#if RedisCommandSpendTime
            m_sw.Stop();
            m_spendMillisecArr[0] = m_sw.ElapsedMilliseconds;
            m_sw.Restart();
#endif
            try
            {
                if (m_script.m_SHA == null || redisCli.HasLuaScript(m_script.m_SHA) == false)
                {
                    m_script.m_SHA = redisCli.LoadLuaScript(m_script.m_Body);
                }
                m_theReturn = redisCli.ExecLuaShaAsList(m_script.m_SHA, m_luaArgv);
            }
            catch (Exception ex)
            {
                m_Err = eRedisAccessError.Command_Exec_Fail;
                SvLogger.Fatal(ex, "ScriptName={2}\nScriptBody={3} -> {0}\n{1}.", ex.Message, ex.StackTrace, m_script.m_Name, m_script.m_Body);
            }

#if RedisCommandSpendTime
            m_sw.Stop();
            m_spendMillisecArr[1] = m_sw.ElapsedMilliseconds;
            m_sw.Restart();
#endif

            return(m_Err);
        }