首页新闻找找看学习计划

StackExchange.Redis执行Lua的问题

1
悬赏园豆:30 [已关闭问题] 关闭于 2017-12-12 13:34
  public async Task<RedisResult> Test()
        {
      //EVAL
string lua = @"local result={} for i, v in ipairs(KEYS) do result[i] = redis.call('hgetall',v) end return result"; var res1 = LuaScript.GetCachedScriptCount(); var res = await _client.ScriptEvaluateAsync(lua, new RedisKey[] { "people:1", "people:2", "people:3" });       
       //EVALSHA
var prepared = LuaScript.Prepare(lua); var loaded = await prepared.LoadAsync( RedisConnection.GenerateConnection.GetServer(RedisConnection.GenerateConnection.GetEndPoints().First())); var res2 = await loaded.EvaluateAsync(_client, new RedisKey[] { "people:1", "people:2", "people:3" }); var res3 = LuaScript.GetCachedScriptCount(); var res4 = await loaded.EvaluateAsync(_client, new RedisKey[] { "people:1", "people:2", "people:3" }); return res; }

如上代码,使用EVAL方式执行LUA没问题,正常返回。

使用第二段EVALSHA方式返回为空。不报错

使用stackexchange.redis官方的方式写的呀,方式一模一样的呢。

有使用过stackexchange.redis的EVALSHA方式执行LUA的园友帮忙分享下经验,和分析下错误。

坦荡的主页 坦荡 | 初学一级 | 园豆:105
提问于:2017-01-08 16:33
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册