'Clean the cache if it\'s time to do so.'

def _maybe_clean(self):

    now = time.time()
    if (self.next_cleaning <= now):
        keys_to_delete = []
        for (k, v) in self.data.items():
            if (v.expiration <= now):
                keys_to_delete.append(k)
        for k in keys_to_delete:
            del self.data[k]
        now = time.time()
        self.next_cleaning = (now + self.cleaning_interval)
