incr_multi with differing delta values
incr_multi seems to only be able to increment each key by the same amount. Can we add support for different deltas for each key?
Also, incr_multi seems to be missing from the sphinx docs.
We could probably check if the object given to incr_multi is a mapping or a sequence. However, I dislike the idea of having a self-contradictory API -- what does mc.incr_multi({'key': 3}, delta=2) do?
On 16 mar 2012, at 05:34, David Underhill wrote:
incr_multi seems to only be able to increment each key by the same amount. Can we add support for different deltas for each key?
Also, incr_multi seems to be missing from the sphinx docs.
Reply to this email directly or view it on GitHub: https://github.com/lericson/pylibmc/issues/83
What if both the delta and key arguments could be scalar values or sequences?
mc.incr_multi(key, delta=2)
mc.incr_multi([key1, key2], delta=[delta1, delta2])
No, that's not a good idea. A mapping would be better for such a purpose, I think.
mc.incr_multi(['a', 'b'], delta=2)
mc.incr_multi({'a': 2, 'b': 3})
These two are useful. One solution is making combinations of the two raise an exception. I strongly question the usefulness of such an API, but that goes for incr_multi at all, really. Would need to whack out a patch to weigh complexity vs usefulness.
Personally I prefer the mapping too, but most of all I'd just like to be able to batch increment operations regardless of the interface you choose to provide :).