I've posted this at stackoverflow, but got no response. I hope someone here would know the answer...
I using the go-redis library to check memory usage of a specific key on a Redis cluster. The library fails sporadically with error "redis: nil" which usually means that it accesses the wrong redis instance to find the key. The go-redis library is using the Redis CLI: "command" to get the list of arguments for each command, and to find where is the redis key position in the arguments list.
Specifically for the memory CLI, the output of the "command" CLI is:
157) 1) "memory"
2) (integer) -2
3) 1) readonly
2) random
4) (integer) 0
5) (integer) 0
6) (integer) 0
The Redis document: https://redis.io/commands/command items 4 and 5 are the positions of the first key in arguments, and the last key in arguments.
But the values are zero? According to the memory CLI document: https://redis.io/commands/memory-usage The items 4 and 5 should both have the value 3.
Is this a bug in the output of the redis "command" CLI, or am I misunderstanding this?
redis cluster-computing go-redis
Comment From: oranagra
@alonana thanks for reaching out.
this issue was recently discussed in https://github.com/redis/redis/pull/7455
in a nut shell, it would be wrong for COMMAND command to respond that the first and last key of the MEMORY command is 3. since that's only true for the MEMORY USAGE sub-command, and not for other sub-commands.
the right thing to do is that go-redis look for the movablekeys in the output and then issue a COMMAND GETKEYS request. or alternatively go-redis can add specific handling for the MEMORY USAGE, like it does for EVAL.
Comment From: oranagra
i see fix was merged to go-redis. thanks. closing this issue.
Comment From: Pythonspark1
// The new built-in function allocates memory. The first argument is a type, // not a value, and the value returned is a pointer to a newly // allocated zero value of that type.