search

Home  >  Q&A  >  body text

Redis operation in php uses lua, but it cannot be executed consistently. Please help everyone take a look.

1.When using redis.eval to operate the Lua script in php, an error occurred. I don’t know what the problem is. Please help me. Thank you

The set value is entered, use eval to call lua to detect if the value of my:lock is this value, delete it, but this step is wrong, can you help me take a look, thank you

習慣沉默習慣沉默2779 days ago703

reply all(2)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:07:41

    I don’t know much about PHP, but I am familiar with redis. I guess there is something wrong here.
    eval($script, $a, 1)eval($script, $a, 1)
    因为redis默认eval命令的参数依次是:lua脚本,键值对个数,所有的键名,所有的值。
    我不知道php里的redis库有没有修改这个顺序,如果不对请忽略这个答案吧,否则你可以试试下面这样。
    eval($script, 1, $a)
    另外,这里$a是个数组,其实应该拆开来传值吧?
    eval(#script, 1, $a[0], $a[1])Because the parameters of redis’ default eval command are: lua script, the number of key-value pairs, all key names, and all values.

    I don’t know if the redis library in php has modified this order. If it is wrong, please ignore this answer, otherwise you can try the following. 🎜eval($script, 1, $a)🎜In addition, $a here is an array. In fact, it should be split to pass the value, right? 🎜eval(#script, 1, $a[0], $a[1])🎜

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 13:07:41

    What I’m curious about is why do I need to adjust Lua in PHP to implement this logic? If you use PHP to read the value of this key from redis and compare it, can you realize the logic you want?

    reply
    0
  • Cancelreply