fiorix/txredisapi — pull request #17 by jeethu (2012-03-29 18:12:26+00:00)
Title: Sorted sets cleanup

Hi @fiorix, @gleicon,

I've got a slightly large pull request this time. This fixes to [#8](https://github.com/fiorix/txredisapi/issues/8).

ZREVRANGEBYSCORE wasn't implemented (txredis doesn't have it as well), implemented it.
ZRANGE, ZREVRANGE, ZRANGEBYSCORE & ZREVRANGEBYSCORE take an optional withscores argument, which defaults to False.
With the withscores argument set to True, aforementioned 4 commands return lists of tuples (of form (member, score)) instead of flat lists (which are returned otherwise).
ZRANGEBYSCORE, ZREVRANGEBYSCORE take optional offset and count parameters.

The optional aggregate argument to ZINTERSTORE, ZUNIONSTORE commands take the builtin min, max & sum functions as well as strings 'MIN', 'MAX', 'SUM' (case insensitive, as before). Anything besides these 6 options raises an InvalidData exception.

Added sensible defaults to all sorted set methods wherever possible (mostly inspired by txredis).

All of the above changes are backed by a test case in test_sortedsets.py.
I've verified (with trial --coverage) that this completely covers all the sorted set methods.
The methods testing ZINTERSTORE and ZUNIONSTORE are little kludgy, please feel free to improve on them.

Also, made ShardedMethods a frozen set instead of a list. O(1) lookups instead of O(N) lookups ought to make sharded command lookups a little bit faster.

Added zcount, zdecr, zincrby, zrevrangebyscore, zrevrank, zrank, zremrangebyrank to ShardedMethods, since they don't have any side effects (unlike zinterstore & zunionstore).
Removed the re.I flag from the _findhash regex used by ShardedConnections, since there isn't any alphabetic lookup happening in it.

Another minor unrelated change, reduced values in test_large_multibulk_int & test_large_multibulk_str by a factor of 10, I've verified that the tests still fail on commits before [4f80c24c9e](https://github.com/fiorix/txredisapi/commit/4f80c24c9e9b1383f570cbfa593b73cf77e3f7ea), in which I'd fixed the error.
This is because there are 48 tests now (up from 34 before). And it takes about half a minute to run on my MBP.

Finally, in another tiny commit, I've backported jason-oster's floating point fix from cyclone (See pull request [#48](https://github.com/fiorix/cyclone/issues/48) on the cyclone repo).