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.