Git Product home page Git Product logo

Comments (4)

gwelr avatar gwelr commented on May 22, 2024

code is:
local key="foo"
local otherkey="bar"
val1,val2 = lRedis:pipeline(function()
set_cardinality("k:" .. key .. ":list")
get("k:" .. otherkey .. ":val")
end)
lua: test.lua:x: unknown redis command: key

from redis-lua.

nrk avatar nrk commented on May 22, 2024

Are you using the latest version of redis-lua? It's strange because your snippet works for me (well, actually there's another problem I've just noticed but it's unrelated, I'll file a bug myself later).

The local variables key and otherkey should be captured by the closure, can you try with the following snippet and see what happens?

local key = "foo"
local otherkey = "bar"

redis:pipeline(function(g)
    g.print(key)
    g.print(otherkey)
end)

It's a whole different matter if key and otherkey are defined as global variables, this won't work currently in redis-lua:

key = "foo"
otherkey = "bar"

local replies = redis:pipeline(function()
    set_cardinality("k:" .. key .. ":list")
    get("k:" .. otherkey .. ":val")
end)

In this case you should do just like in my first snippet, where the original _G is passed to the closure as an argument:

key="foo"
otherkey="bar"

local replies = redis:pipeline(function(g)
    set_cardinality("k:" .. g.key .. ":list")
    get("k:" .. g.otherkey .. ":val")
end)

Pipeline handling will change for sure in future releases of redis-lua since it's been proved to be error prone in some cases, and this is probably one of them.

from redis-lua.

nrk avatar nrk commented on May 22, 2024

I'm going to close this issue in a few days if no further details will be posted in the meanwhile. With the next major release this is getting fixed anyway by using a little different approach for pipelines.

from redis-lua.

nrk avatar nrk commented on May 22, 2024

I'm closing this issue since no further details have been provided.

from redis-lua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.