simon_xia
simon_xia

Reputation: 2544

Can we do pipeline in lua script of redis

for example

I have several set commands, and I don't care the return value of them, in my lua script, I have to write several redis.call('set', key, val) .

Is there any way like pipeline, so I can do them together. Maybe more efficient?

Upvotes: 3

Views: 3289

Answers (2)

Itamar Haber
Itamar Haber

Reputation: 50112

No - there's no way to pipeline Redis calls from a Lua script, or batch them. Note that calling redis.call is very efficient so you shouldn't worry too much about that anyway.

As @deltheil pointed out, you can however "group" multiple calls to the same command if you use its variadic form. While of less importance for Lua scripts, this is definitely the recommend practice.

Upvotes: 6

deltheil
deltheil

Reputation: 16121

What about using MSET?

$ redis-cli 
127.0.0.1:6379> eval 'redis.call("mset", "foo", "bar", "scm", "git", "test", "ok")' 0
(nil)
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> get scm
"git"
127.0.0.1:6379> get test
"ok"

Upvotes: 5

Related Questions