def trim(self):
        '''Remove items that are expired or exceed the max size.'''
        now_time = time.time()

        while self._seq and self._seq[0].expire_time < now_time:
            item = self._seq.popleft()
            del self._map[item.key]

        if self._max_items:
            while self._seq and len(self._seq) > self._max_items:
                item = self._seq.popleft()
                del self._map[item.key]
def trim ( self ) : now_time = time . time ( ) while self . _seq and self . _seq [ 0 ] . expire_time < now_time : item = self . _seq . popleft ( ) del self . _map [ item . key ] if self . _max_items : while self . _seq and len ( self . _seq ) > self . _max_items : item = self . _seq . popleft ( ) del self . _map [ item . key ]
Remove items that are expired or exceed the max size.