    def cleanup(self, lru_retention_hours: int = 72):
        """See docstring of implemented method interface in parent class"""
        _LOGGER.info(
            f"CACHE: Cleaning up build cache below {self.cache_dir}. Folders last used more than {lru_retention_hours} hours ago will be deleted."
        )
        touch(os.path.join(self.cache_dir, ".last_cleaned"))
        if os.path.isdir(self.cache_dir):
            now = datetime.now()
            age_limit = timedelta(hours=lru_retention_hours)

            for dirpath in os.scandir(self.cache_dir):
                if os.path.isdir(dirpath):
                    # Get the modification time of the directory and convert it to a datetime object
                    mtime = os.path.getmtime(dirpath)
                    modification_time = datetime.fromtimestamp(mtime)

                    # Check if the directory is older than N hours
                    if now - modification_time > age_limit:
                        _LOGGER.info(f"CACHE: Deleting {dirpath}")
                        shutil.rmtree(dirpath)
See docstring of implemented method interface in parent class
python/aitemplate/backend/build_cache_base.py