Ejemplo n.º 1
0
 def _enforce_limits(self, new_value):
     additional_size = memory.getsizeof(new_value) / 8
     while len(self._cache) > 0 and not (len(self._cache) <= self._max_keys and
                                         (memory.getsizeof(self._cache) + additional_size) / 8 <= self._max_bytes):
         self.logger.debug('shrinking limited memory cache')
         self._cache.popitem(last=False)
Ejemplo n.º 2
0
 def print_limit(self, additional_size=0):
     self.logger.info('LimitedMemoryBackend at {}({}) keys -- {}({}) Byte'
                      .format(len(self._cache), self._max_keys,
                              memory.getsizeof(self._cache) / 8, self._max_bytes))