Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incr_multi with differing delta values #83

Open
dound opened this issue Mar 16, 2012 · 4 comments
Open

incr_multi with differing delta values #83

dound opened this issue Mar 16, 2012 · 4 comments

Comments

@dound
Copy link

dound commented Mar 16, 2012

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.

@lericson
Copy link
Owner

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:
#83

@dound
Copy link
Author

dound commented Mar 18, 2012

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

@lericson
Copy link
Owner

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.

@dound
Copy link
Author

dound commented Mar 19, 2012

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants