Commit 8bc2699c authored by Vincent Pelletier's avatar Vincent Pelletier

Provide a way to update MQ cache without changing entry level.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2491 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7c57a189
......@@ -341,6 +341,15 @@ class MQ(object):
__delitem__ = invalidate
def update(self, key, callback):
"""
Update entry without changing its level.
"""
data = self._data[key]
if data.level < 0:
raise KeyError(key)
data.value = callback(data.value)
# Here is a test.
if __name__ == '__main__':
import hotshot, hotshot.stats
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment