Redis可以禁用对管道命令的答复吗?

Redis可以禁用对管道命令的答复吗?,第1张

Redis可以禁用对管道命令的答复吗?

是的…至少在2.6中。您可以在LUA脚本中执行此 *** 作,只需让LUA脚本返回空结果即可。这是使用booksleeve客户端的:

const int DB = 0; // any database number// prime some initial valuesconn.Keys.Remove(DB, new[] {"a", "b", "c"});conn.Strings.Increment(DB, "b");conn.Strings.Increment(DB, "c");conn.Strings.Increment(DB, "c");// run the script, passing "a", "b", "c", "c" to// increment a & b by 1, c twicevar result = conn.scripting.eval(DB,    @"for i,key in ipairs(KEYS) do redis.call('incr', key) end",    new[] { "a", "b", "c", "c"}, // <== aka "KEYS" in the script    null); // <== aka "ARGV" in the script// check the incremented valuesvar a = conn.Strings.GetInt64(DB, "a");var b = conn.Strings.GetInt64(DB, "b");var c = conn.Strings.GetInt64(DB, "c");Assert.IsNull(conn.Wait(result), "result");Assert.AreEqual(1, conn.Wait(a), "a");Assert.AreEqual(2, conn.Wait(b), "b");Assert.AreEqual(4, conn.Wait(c), "c");

incrby
通过将“ by”数字作为参数传递来做同样的事情,将中间部分更改为:

// run the script, passing "a", "b", "c" and 1, 1, 2// increment a & b by 1, c twicevar result = conn.scripting.eval(DB,    @"for i,key in ipairs(KEYS) do redis.call('incrby', key, ARGV[i]) end",    new[] { "a", "b", "c" }, // <== aka "KEYS" in the script    new object[] { 1, 1, 2 }); // <== aka "ARGV" in the script


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4988064.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存