[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[p2-dev] The cache policy of repo manager

Hello dev,

I do debug the implementation of repo manager, and find the repo manger
would cache the location and its corresponding repo that is held by a
SoftReference object. It won't actually load the repo again for the
cached location until the cached repo object has been GC. It's a good
practice, as well improve the performance in case of loading the same
repo frequently. However, I'm confused by below code snippet,

	protected IRepository basicGetRepository(URI location) {
			......................
			IRepository repo = (IRepository)
info.repository.get();
			//update our repository info because the
repository may have changed
			if (repo != null)
				addRepository(repo, false, null);
			return repo;
		}
	}

The comment tells me the repo may have changed, so update the repository
info. If so, why still returns the cached repo though the real repo
might have changed? Why reset the known suffix for that repo even if
it's necessary to update the repo info? My understand is that the suffix
escalates the hit rate of loading when there are multiple repo
factories. If the repo info records a suffix for the location, repo
manager would firstly use the factory that is bind to the suffix. It's
also a rare situation that the type of repo is changed. So it would be
higher hit rate to load the repo again if keeping the value of suffix.

Kane(Zhu, Meng Xin)
mail: kane.zhu@xxxxxxxxxxxxx