Can redis disable responses for pipelined commands?

I am currently developing a cache that requires an increase in the number of hundreds of counters for each call like this:

redis.pipelined do keys.each{ |key| redis.incr key } end 

In my profiling, I now saw that the answers that I do not need are still collected by redis pearls and lose some time value. Can I tell redis somehow that I am not interested in the answers? Is there a better way to increase the number of values.

I did not find the MINCR command, for example ..

Thanks in advance!

+4
source share
3 answers

Yes ... at 2.6, at least. You can do this in a LUA script, and just the LUA script returns an empty result. This uses the bookleeve client:

 const int DB = 0; // any database number // prime some initial values conn.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 twice var 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 values var 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"); 

Or do the same with incrby , passing the numbers "by" as arguments, change the middle part to:

 // run the script, passing "a", "b", "c" and 1, 1, 2 // increment a & b by 1, c twice var 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 
+5
source

No, It is Immpossible. This is not to say that Radish did not answer.

The only way to avoid synchronously waiting for answers at some points is to run a fully asynchronous client (for example, node.js or hiredis in asynchronous mode).

+2
source

Version 3.2 of Redis supports this explicitly:

https://redis.io/commands/client-reply

The CLIENT REPLY command determines whether the server will respond to client commands. The following modes are available: ON. This is the default mode in which the server returns a response to each command. OFF In this mode, the server will not respond to client commands. MISS. This mode skips the command response immediately after it.

Return value When called with the OFF or SKIP subcommands, no response is made. When called with ON: Simple line response: OK.

0
source

Source: https://habr.com/ru/post/1441465/


All Articles