Commit 30231671 authored by Vincent Pelletier's avatar Vincent Pelletier

Use _evict to prune data for size.

It updates self._size, so we must read it from there each time.
This also uses the history queue, which was ignored by this code, hence
this should make better use of MQ algorithm.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2552 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent f0ccad70
......@@ -312,21 +312,16 @@ class MQ(object):
self._evict(data.key)
# Limit the size.
size = self._size
max_size = self._max_size
if size > max_size:
if self._size > max_size:
for cache_buffer in cache_buffers:
while size > max_size:
element = cache_buffer.shift()
while self._size > max_size:
element = cache_buffer.head()
if element is None:
break
data = element.data
del self._data[data.key]
size -= sizeof(data.value)
del data.value
if size <= max_size:
self._evict(element.data.key)
if self._size <= max_size:
break
self._size = size
__setitem__ = store
......
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