Improve clear of runtime cache.

This commit is contained in:
André Cruz
2013-07-06 14:56:13 +01:00
parent e51827bfcd
commit 9517191e35
3 changed files with 14 additions and 3 deletions

View File

@@ -273,6 +273,16 @@ ResolveCache.prototype.list = function () {
// ------------------------
ResolveCache.clearRuntimeCache = function () {
// Note that _cache refers to the static _cache variable
// that holds other caches per dir!
// Do not confuse it with the instance cache
// Clear cache of each directory
this._cache.forEach(function (cache) {
cache.reset();
});
// Clear root cache
this._cache.reset();
};

View File

@@ -331,6 +331,7 @@ GitResolver.branches = function (source) {
};
GitResolver.clearRuntimeCache = function () {
// Reset cache for branches, tags, etc
mout.object.forOwn(GitResolver._cache, function (lru) {
lru.reset();
});

View File

@@ -25,9 +25,9 @@ function names(obj, prefix, stack) {
}
function clearRuntimeCache() {
// Note that the runtime cache is only cleared statically
// If you got an instance of an architecture component that holds cache,
// you should get rid of it and instantiate a new one after calling this
// Note that in edge cases, some architecture components instance's
// in-memory cache might not have been cleared.
// If that's a problem, you should create and fresh instances instead.
PackageRepository.clearRuntimeCache();
}