diff --git a/lib/core/ResolveCache.js b/lib/core/ResolveCache.js index 65652e03..d8ee30dd 100644 --- a/lib/core/ResolveCache.js +++ b/lib/core/ResolveCache.js @@ -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(); }; diff --git a/lib/core/resolvers/GitResolver.js b/lib/core/resolvers/GitResolver.js index 6a02d4fb..7257c68c 100644 --- a/lib/core/resolvers/GitResolver.js +++ b/lib/core/resolvers/GitResolver.js @@ -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(); }); diff --git a/lib/index.js b/lib/index.js index 0f888620..e7af14ef 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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(); }