code: def apt_cache(in_memory=True, progress=None):
      
      from apt import apt_pkg
      apt_pkg.init()
      if in_memory:
          apt_pkg.config.set("Dir::Cache::pkgcache", "")
          apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
      return apt_pkg.Cache(progress)
docs: Build and return an apt cache.