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): ...@@ -312,21 +312,16 @@ class MQ(object):
self._evict(data.key) self._evict(data.key)
# Limit the size. # Limit the size.
size = self._size
max_size = self._max_size max_size = self._max_size
if size > max_size: if self._size > max_size:
for cache_buffer in cache_buffers: for cache_buffer in cache_buffers:
while size > max_size: while self._size > max_size:
element = cache_buffer.shift() element = cache_buffer.head()
if element is None: if element is None:
break break
data = element.data self._evict(element.data.key)
del self._data[data.key] if self._size <= max_size:
size -= sizeof(data.value)
del data.value
if size <= max_size:
break break
self._size = size
__setitem__ = store __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