Machine Level Cache Part 1

Current behavior (NuGet 1.2)

In the current version of NuGet (1.2), when packages are installed into a project, the package file is stored in the packages folder solution. When the same package is installed into another project (assuming it can be installed), the package is not downloaded again. Instead, the one at the solution level is used.

However, every time a package is installed, the bytes are also stored in memory. That way, if you close the solution (but keep VS open) and open a different solution, and then install the package, it doesn’t need to be downloaded.

Problem: However, this adds a lot of memory to the working set and probably doesn’t really fit the workflow of many people, who may be more inclined to open a new VS instance when ready to work on another solution.

Solution

NuGet 1.3 supports storing packages in a machine level cache rather than in-memory. This will reduce the working set while also improving throughput when installing common packages. The local machine cache feature will be improved in future versions of NuGet hence the “Part 1” suffix.

Design

Storage

Packages will be stored in NuGet’s AppData folder for the local profile only, never in the roaming profile.

%LocalAppData%\NuGet\Cache

On a typical machine, that would be:

C:\Users\UserName\AppData\Local\NuGet\Cache

Settings

Clear Cache button: We’re going to combine the Recent Packages setting with a setting to clear the machine cache. See the following mockup.

Options (4)

The letter “p” in package should be the access key (and thus underlined). We need to rename the settings node in the left tree view to be named General and probably sorted before “Package Sources”.

Workflow

  1. First time a package is installed, it's copied into this machine cache.
  2. Once we determine the "latest" version of the package (in the same way we do today), we'll install it from the local/machine cache if it's there, otherwise we'll download it and update the local cache.

This is effectively the exact same workflow in NuGet 1.2 except we stop storing packages in memory and store them on disk instead.

Last edited Apr 4, 2011 at 11:27 PM by haacked, version 5