pylibmc icon indicating copy to clipboard operation
pylibmc copied to clipboard

incr_multi with differing delta values

Open dound opened this issue 13 years ago • 4 comments

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.

dound avatar Mar 16 '12 04:03 dound

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

lericson avatar Mar 17 '12 16:03 lericson

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])

dound avatar Mar 18 '12 04:03 dound

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.

lericson avatar Mar 18 '12 12:03 lericson

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 :).

dound avatar Mar 19 '12 17:03 dound