antirez/redis — pull request #668 by ecto (2012-09-10 16:48:28+00:00)
Title: Add "count" command

Hey,

I was writing some tests for a project I was working on today, and realize that this command didn't exist (I thought it did, for some reason). I figured I would code it up for my own use.

This function basically re-implements the `keysCommand`, but returns the amount of matched keys instead of the keys themselves. The same functionality is possible by simply checking the number of keys in the response to a `keys` query on the client, but implementing it server-side saves resources, saves a step, and feels natural.

````
redis 127.0.0.1:6379> count *
(integer) 0
redis 127.0.0.1:6379> set foo bar
OK
redis 127.0.0.1:6379> set baz qux
OK
redis 127.0.0.1:6379> count *
(integer) 2
redis 127.0.0.1:6379> count f*
(integer) 1
````

If this has been previously discussed (I don't keep up-to-date with the mailing list) and found to be superfluous, or if you just don't want it in Redis, I totally understand. If you okay this command, I can provide documentation and tests in the next day or two.

Looking forward to your thoughts.