cubicweb/utils.py
changeset 12303 198cb7d7b4ac
parent 12046 9056a41d91ba
child 12305 9fd7d496e27e
equal deleted inserted replaced
12302:0d474f888f4a 12303:198cb7d7b4ac
   682                     return
   682                     return
   683                 if (current_size - datalen) / datalen > .1:
   683                 if (current_size - datalen) / datalen > .1:
   684                     break
   684                     break
   685                 level = v
   685                 level = v
   686         else:
   686         else:
   687             # we removed cruft but everything is permanent
   687             # we removed cruft
   688             if len(self._data) >= self._max:
   688             if len(self._data) >= self._max:
   689                 logger.warning('Cache %s is full.' % id(self))
   689                 if len(self._permanent) >= self._max:
   690                 self._clear()
   690                     # we really are full with permanents => clear
       
   691                     logger.warning('Cache %s is full.' % id(self))
       
   692                     self._clear()
       
   693                 else:
       
   694                     # pathological case where _transient was probably empty ...
       
   695                     # drop all non-permanents
       
   696                     to_drop = set(self._data.keys()).difference(self._permanent)
       
   697                     for k in to_drop:
       
   698                         # should not be in _transient
       
   699                         assert k not in self._transient
       
   700                         self._data.pop(k, None)
   691 
   701 
   692     def _usage_report(self):
   702     def _usage_report(self):
   693         with self._lock:
   703         with self._lock:
   694             return {'itemcount': len(self._data),
   704             return {'itemcount': len(self._data),
   695                     'transientcount': len(self._transient),
   705                     'transientcount': len(self._transient),