def prune(self):
        """
        Removes all cached image files above the cache's maximum
        size. Returns a tuple containing the total number of cached
        files removed and the total size of all pruned image files.
        """
        max_size = self.conf.image_cache_max_size
        current_size = self.driver.get_cache_size()
        if max_size > current_size:
            logger.debug(_("Image cache has free space, skipping prune..."))
            return (0, 0)

        overage = current_size - max_size
        logger.debug(_("Image cache currently %(overage)d bytes over max "
                       "size. Starting prune to max size of %(max_size)d ") %
                     locals())

        total_bytes_pruned = 0
        total_files_pruned = 0
        entry = self.driver.get_least_recently_accessed()
        while entry and current_size > max_size:
            image_id, size = entry
            logger.debug(_("Pruning '%(image_id)s' to free %(size)d bytes"),
                         {'image_id': image_id, 'size': size})
            self.driver.delete_cached_image(image_id)
            total_bytes_pruned = total_bytes_pruned + size
            total_files_pruned = total_files_pruned + 1
            current_size = current_size - size
            entry = self.driver.get_least_recently_accessed()

        logger.debug(_("Pruning finished pruning. "
                       "Pruned %(total_files_pruned)d and "
                       "%(total_bytes_pruned)d.") % locals())
        return total_files_pruned, total_bytes_pruned
dataset/ETHPy150Open rcbops/glance-buildpackage/glance/image_cache/__init__.py/ImageCache.prune/original