#14299: Add additional cache.*_many functions
------------------------------------------+---------------------------------
Reporter: manfre | Owner: manfre
Status: new | Milestone: 1.3
Component: Cache system | Version: SVN
Keywords: cache, add_many, offset_many | Stage: Unreviewed
Has_patch: 1 |
------------------------------------------+---------------------------------
It would be helpful to have the cache framework allow backends to
implement more bulk operations. Attached is a patch that adds support for
``add_many()`` and ``offset_many()``.
``add_many()``
To add multiple values more efficiently, use ``add_many()`` to pass a
dictionary
of key-value pairs. ``add_many()`` returns a dictionary with all the keys
passed
and their values being a bool indicating whether or not the value was
added::
{{{
>>> cache.set('a', 1)
>>> cache.add_many({'a': 2, 'b': 1})
{'a': False, 'b': 1}
}}}
``offset_many()``
To increment and decrement multiple values more efficiently, use
``offset_many()`` to pass a dictionary of key-value pairs, where the value
is
the delta you would like apply to the existing value. ``offset_many()``
returns a dictionary with all the keys passed and their new value. If a
key is
not found or there was an error, its value will be False::
{{{
>>> cache.set_many({'a': 10, 'b': 10})
>>> cache.offset_many({'a': 1, 'b': -1, 'c': 1})
{'a': 11, 'b': 9, 'c': False}
}}}
Attached patch is against trunk, includes tests and docs.
--
Ticket URL: <http://code.djangoproject.com/ticket/14299>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.