Clearing your p2 cache

Clearing your p2 cache

There are only two hard things in Computer Science: cache invalidation, naming things and off by one errors. (reference)

I appears that P2 (em, p2) suffers from both of these things, but today I’m going to focus on the first one, caching problems.  No matter what we do regarding caching repositories, it seems that we get it wrong.  Some people argue that we don’t cache aggressively enough while others think that the out-of-date caches, even for a few minutes, is not acceptable. While I don’t want to start a political argument on a Friday, I did want to provide a technical tip to help.

If you find that p2 is caching your repositories too aggressively (or it seems to have remembered a bad repository which as since been fixed), you can instruct p2 to reload the cache.  Choose Preferences -> Install / Update -> Available Software Sites.  Select the site you want to reload, and press the Reload button.

Thanks Lars for reminding me to blog about this.

For more Eclipse Tips and Tricks (and the annual Top 10 List), why not follow me on twitter:

  • Sharon Snyder
    Posted at 17:57, 2012-08-31

    How do you call the reload programmatically? I have an RCP application that runs an auto-update when the user logs into it….so this would help us ensure they are always using the latest and greatest!


  • Ian Bull
    Posted at 02:50, 2012-09-08

    If you acquire the IMetadataRepositoryManager, there is a refreshRepository method you can call. This will clear the cache. There is a similar method on the artifact repository manager.

    Another option is to remove and re-load the repo. This will also remove the cache.

    Hope that helps.

  • Sharon Snyder
    Posted at 14:17, 2012-09-10

    Thanks Ian. We’ll give it a try!

  • Sharon Snyder
    Posted at 17:50, 2012-09-10

    One more question – how long is the cache valid for? What determines that the cache is invalid and it needs to be refreshed?