{"action":"created","comment":{"url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/comments/40715720","id":40715720,"diff_hunk":"@@ -0,0 +1,68 @@\n+﻿using System;\n+using System.Collections.Concurrent;\n+using System.Collections.Generic;\n+using System.Linq;\n+using NuGet.Protocol.Core.Types;\n+\n+namespace NuGet.CommandLine\n+{\n+    /// <summary>\n+    /// A singleton caching source repository provider.\n+    /// </summary>\n+    public class CommandLineSourceRepositoryProvider : ISourceRepositoryProvider\n+    {\n+        private readonly Configuration.IPackageSourceProvider _packageSourceProvider;\n+        private List<Lazy<INuGetResourceProvider>> _resourceProviders;\n+        private List<SourceRepository> _repositories = new List<SourceRepository>();\n+\n+        // There should only be one instance of the source repository for each package source.\n+        private static ConcurrentDictionary<Configuration.PackageSource, SourceRepository> _sources \n+            = new ConcurrentDictionary<Configuration.PackageSource, SourceRepository>();\n+\n+        public CommandLineSourceRepositoryProvider(Configuration.IPackageSourceProvider packageSourceProvider)\n+        {\n+            _packageSourceProvider = packageSourceProvider;\n+\n+            _resourceProviders = new List<Lazy<INuGetResourceProvider>>();\n+            _resourceProviders.AddRange(Protocol.Core.v2.FactoryExtensionsV2.GetCoreV2(Repository.Provider));\n+            _resourceProviders.AddRange(Protocol.Core.v3.FactoryExtensionsV2.GetCoreV3(Repository.Provider));\n+\n+            // Refresh the package sources\n+            Init();\n+        }\n+\n+        /// <summary>\n+        /// Retrieve repositories. This does not include cached repos.\n+        /// </summary>\n+        public IEnumerable<SourceRepository> GetRepositories()\n+        {\n+            return _repositories;\n+        }\n+\n+        /// <summary>\n+        /// Create a repository and add it to the cache.\n+        /// </summary>\n+        public SourceRepository CreateRepository(Configuration.PackageSource source)\n+        {\n+            return _sources.GetOrAdd(source, new SourceRepository(source, _resourceProviders));\n+        }\n+\n+        public Configuration.IPackageSourceProvider PackageSourceProvider\n+        {\n+            get { return _packageSourceProvider; }\n+        }\n+\n+        private void Init()","path":"src/NuGet.CommandLine/CommandLineSourceRepositoryProvider.cs","position":55,"original_position":55,"commit_id":"687f6fdaa6fd1102b88ade4f0f57b21740f6fa31","original_commit_id":"687f6fdaa6fd1102b88ade4f0f57b21740f6fa31","user":{"login":"yishaigalatzer","id":1238711,"avatar_url":"https://avatars.githubusercontent.com/u/1238711?v=3","gravatar_id":"","url":"https://api.github.com/users/yishaigalatzer","html_url":"https://github.com/yishaigalatzer","followers_url":"https://api.github.com/users/yishaigalatzer/followers","following_url":"https://api.github.com/users/yishaigalatzer/following{/other_user}","gists_url":"https://api.github.com/users/yishaigalatzer/gists{/gist_id}","starred_url":"https://api.github.com/users/yishaigalatzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yishaigalatzer/subscriptions","organizations_url":"https://api.github.com/users/yishaigalatzer/orgs","repos_url":"https://api.github.com/users/yishaigalatzer/repos","events_url":"https://api.github.com/users/yishaigalatzer/events{/privacy}","received_events_url":"https://api.github.com/users/yishaigalatzer/received_events","type":"User","site_admin":false},"body":"why is this a separate method? Its not being called from anywhere else, and it doesn't \"refresh\" anything","created_at":"2015-09-29T19:15:15Z","updated_at":"2015-09-29T19:15:15Z","html_url":"https://github.com/NuGet/NuGet.PackageManagement/pull/102#discussion_r40715720","pull_request_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/102","_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/comments/40715720"},"html":{"href":"https://github.com/NuGet/NuGet.PackageManagement/pull/102#discussion_r40715720"},"pull_request":{"href":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/102"}}},"pull_request":{"url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/102","id":46123867,"html_url":"https://github.com/NuGet/NuGet.PackageManagement/pull/102","diff_url":"https://github.com/NuGet/NuGet.PackageManagement/pull/102.diff","patch_url":"https://github.com/NuGet/NuGet.PackageManagement/pull/102.patch","issue_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues/102","number":102,"state":"open","locked":false,"title":"nuget.exe 3.2.1 perf improvements (part 2)","user":{"login":"emgarten","id":6381138,"avatar_url":"https://avatars.githubusercontent.com/u/6381138?v=3","gravatar_id":"","url":"https://api.github.com/users/emgarten","html_url":"https://github.com/emgarten","followers_url":"https://api.github.com/users/emgarten/followers","following_url":"https://api.github.com/users/emgarten/following{/other_user}","gists_url":"https://api.github.com/users/emgarten/gists{/gist_id}","starred_url":"https://api.github.com/users/emgarten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emgarten/subscriptions","organizations_url":"https://api.github.com/users/emgarten/orgs","repos_url":"https://api.github.com/users/emgarten/repos","events_url":"https://api.github.com/users/emgarten/events{/privacy}","received_events_url":"https://api.github.com/users/emgarten/received_events","type":"User","site_admin":false},"body":"This change lets nuget.exe keep a single instance of each SourceRepository. Package data is now cached as much as possible to avoid extra network calls.\r\n\r\n* Added CommandLineSourceRepositoryProvider to cache and maintain single instances of each SourceRepository across operations. This allows caching for package info from local repos and for caching index.json in v3 repos. https://github.com/NuGet/Home/issues/1321\r\n* Added the global packages folder as a source along side the machine cache in nuget.exe. \r\n* Local sources will be checked first during a restore. Since there are now two machine caches (v2 and v3) network calls were being made even when the package already existed in a cache, this was not an issue before in 2.8.6 where there was only one machine cache and it was used before making the v2 online call.\r\n* Installing without a set version will cache the package info and download url in the gather cache to be used during resolution.\r\n* Gather cache now stores the target framework since this is used to filter the dependencies. Previously it was possible to get incorrect results across multi-project operations.\r\n* Increased ServicePointManager.DefaultConnectionLimit\r\n* Command line runner was hanging in tests due to the buffer being full when nuget.exe would output a large amount of text, this has been fixed by using the output and error events instead of the stream.\r\n\r\n","created_at":"2015-09-28T06:30:52Z","updated_at":"2015-09-29T19:15:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"04ce3c974d0a138087e2bdd9055a8ded30feb250","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/102/commits","review_comments_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/102/comments","review_comment_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues/102/comments","statuses_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/statuses/687f6fdaa6fd1102b88ade4f0f57b21740f6fa31","head":{"label":"NuGet:dev-cmd-321","ref":"dev-cmd-321","sha":"687f6fdaa6fd1102b88ade4f0f57b21740f6fa31","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":26662893,"name":"NuGet.PackageManagement","full_name":"NuGet/NuGet.PackageManagement","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGet.PackageManagement","description":"NuGet.exe as well a libraries for reading and writing manifests of installed packages","fork":false,"url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement","forks_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/forks","keys_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/events","assignees_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/merges","archive_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/releases{/id}","created_at":"2014-11-14T23:55:44Z","updated_at":"2015-09-01T01:00:09Z","pushed_at":"2015-09-29T01:16:33Z","git_url":"git://github.com/NuGet/NuGet.PackageManagement.git","ssh_url":"git@github.com:NuGet/NuGet.PackageManagement.git","clone_url":"https://github.com/NuGet/NuGet.PackageManagement.git","svn_url":"https://github.com/NuGet/NuGet.PackageManagement","homepage":"","size":8507,"stargazers_count":12,"watchers_count":12,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":4,"forks":10,"open_issues":4,"watchers":12,"default_branch":"dev"}},"base":{"label":"NuGet:dev","ref":"dev","sha":"3d6cf88131280c789d81f543b33df40421ad7e5b","user":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"repo":{"id":26662893,"name":"NuGet.PackageManagement","full_name":"NuGet/NuGet.PackageManagement","owner":{"login":"NuGet","id":968310,"avatar_url":"https://avatars.githubusercontent.com/u/968310?v=3","gravatar_id":"","url":"https://api.github.com/users/NuGet","html_url":"https://github.com/NuGet","followers_url":"https://api.github.com/users/NuGet/followers","following_url":"https://api.github.com/users/NuGet/following{/other_user}","gists_url":"https://api.github.com/users/NuGet/gists{/gist_id}","starred_url":"https://api.github.com/users/NuGet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NuGet/subscriptions","organizations_url":"https://api.github.com/users/NuGet/orgs","repos_url":"https://api.github.com/users/NuGet/repos","events_url":"https://api.github.com/users/NuGet/events{/privacy}","received_events_url":"https://api.github.com/users/NuGet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NuGet/NuGet.PackageManagement","description":"NuGet.exe as well a libraries for reading and writing manifests of installed packages","fork":false,"url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement","forks_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/forks","keys_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/teams","hooks_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/hooks","issue_events_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues/events{/number}","events_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/events","assignees_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/assignees{/user}","branches_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/branches{/branch}","tags_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/tags","blobs_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/refs{/sha}","trees_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/statuses/{sha}","languages_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/languages","stargazers_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/stargazers","contributors_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/contributors","subscribers_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/subscribers","subscription_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/subscription","commits_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/commits{/sha}","git_commits_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/git/commits{/sha}","comments_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/comments{/number}","issue_comment_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues/comments{/number}","contents_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/contents/{+path}","compare_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/merges","archive_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/downloads","issues_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues{/number}","pulls_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls{/number}","milestones_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/milestones{/number}","notifications_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/labels{/name}","releases_url":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/releases{/id}","created_at":"2014-11-14T23:55:44Z","updated_at":"2015-09-01T01:00:09Z","pushed_at":"2015-09-29T01:16:33Z","git_url":"git://github.com/NuGet/NuGet.PackageManagement.git","ssh_url":"git@github.com:NuGet/NuGet.PackageManagement.git","clone_url":"https://github.com/NuGet/NuGet.PackageManagement.git","svn_url":"https://github.com/NuGet/NuGet.PackageManagement","homepage":"","size":8507,"stargazers_count":12,"watchers_count":12,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":4,"forks":10,"open_issues":4,"watchers":12,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/102"},"html":{"href":"https://github.com/NuGet/NuGet.PackageManagement/pull/102"},"issue":{"href":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues/102"},"comments":{"href":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/issues/102/comments"},"review_comments":{"href":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/102/comments"},"review_comment":{"href":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/pulls/102/commits"},"statuses":{"href":"https://api.github.com/repos/NuGet/NuGet.PackageManagement/statuses/687f6fdaa6fd1102b88ade4f0f57b21740f6fa31"}}}}