0

I meet a very weird problem about Redis and its Java client Jedis. I have two list in Redis named workMQ and backupMQ, when I execute llen workMQ in redis-cli, it returns 16. However when I execute jedis.llen("workMQ") in Java code with Jedis, it returns 0. But when new data coming by run jedis.lpush("workMQ", "data")in Java codes, the Redis llen workMQ become 1. Why jedis.llen("workMQ") couldn't recognize the remain 16 data items in this list?

Before this weird problem occur, I did rpoplpush operate with Lua script as follows.

eval "for i = 1, 10 do\r redis.call('rpoplpush', 'backupMQ', 'workMQ')\r end" 0

Actually this Lua script have some errors, the correct one is

eval "for i = 1, 10 do\r redis.call('rpoplpush', KEYS[1], KEYS[2])\r end" 2 backupMQ workMQ

Maybe there is some type error between Redis and Lua. I have executed both of these Lua scripts, but still can't work.

PS: My Jedis client's version is 2.7.2, the latest stable version from Jedis Github.

Thanks for your time.

Solved: After one night, the Redis server magically recognized workMQ's items length, and all is fine. It's really strange.

Armstrongya
  • 795
  • 1
  • 6
  • 9

1 Answers1

0
  1. This weird thing cannot happen. You must got something very wrong. For example, redis-cli can accept command like "llen(workMQ)" ? Or do you actually mean "llen workMQ"?

    I think it's very likely you are using jedis to operate on a different list key than on redis-cli!

  2. The lua problem is simple, you shoud return a value (at your will) at the end of lua script. And if it still didn't work, post the detailed error information for me!

Community
  • 1
  • 1
Murphy Ng
  • 552
  • 3
  • 11
  • Thanks for your reply. 1. It happens. ```llen(workMQ)``` is a spell mistake, actually I'm using ```llen workMQ``` in redis-cli. 2. When I run this Lua script with redis.call, no errors output. – Armstrongya Sep 24 '15 at 02:20