There are several ways to do this without introducing a new command in Redis.
For example, you can populate a temporary set with names that interest you, and then calculate the intersection between the temporary set and zset:
multi sadd tmp David Linda ... and more ... zinterstore res 2 tmp Users weights 0 1 zrange res 0 -1 withscores del tmp res exec
With pipelining this will lead to the generation of only one reverse transition, and you can fill in an arbitrary number of input parameters in tmp.
With Redis 2.6, you can also wrap these lines in a server-side Lua script to finally get a command that accepts an input list and returns the desired result:
eval "redis.call( 'sadd', 'tmp', unpack(KEYS) ); redis.call( 'zinterstore', 'res', 2, 'tmp', 'Users', 'weights', 0, 1 ); local res = redis.call( 'zrange', 'res', 0, -1, 'withscores' ); redis.call( 'del', 'res', 'tmp' ) ; return res " 2 David Linda
We can safely assume that the new command will not be added to Redis, if it can be easily implemented using scripts.
source share