lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


You may probably know that Redis has Lua engine inside, which exposes the `redis.call(...)` function.

Redis is famously single-threaded but if I would want to make it multi-threaded, Lua scripting is one of the bigger barriers to that.
Suppose I would need to protect each `redis.call` command with mutex - it would create potential contention and overhead around each `redis.call` within a script.

But for scripts that look like:
```
redis.call('set', ...)
redis.call('lpush', ....)
```
I could theoretically recognize that these commands are not dependent on each other and pipeline them (batch them within a single protected atomic operation). 

It's different from:
```
local a = redis.call('get', ...)
if a = ...
```
where the lua logic depends on the return value of the call operation and I must run it sequentially. 
From what I saw in practice, many Redis lua scripts used in Redis frameworks have blocks of commands that ignore return values, so they can be batched together.

Roman




On Wed, Feb 22, 2023 at 8:12 AM bil til <biltil52@gmail.com> wrote:
... can you perhaps describe a bit more your application, for which you need it?

(and with what sort of user application you want to use it?)...

... maybe then more clear what you really want to do / why you need
this, or people who do similar things can give you some hints... .


--
Best regards,
     Roman