'Check oldest items and remove them if needed.
Arguments:
now (float): Time of purging -- by default right now.
This can be useful for unit testing.'

def purge(self, now=None):

    now = (now or time.time())
    now = (now() if isinstance(now, Callable) else now)
    if self.maxlen:
        while (len(self._data) > self.maxlen):
            self.pop()
    if self.expires:
        while (len(self._data) > self.minlen >= 0):
            (inserted_time, _) = self._heap[0]
            if ((inserted_time + self.expires) > now):
                break
            self.pop()
