{"action":"opened","issue":{"url":"https://api.github.com/repos/nopSolutions/nopCommerce/issues/1905","repository_url":"https://api.github.com/repos/nopSolutions/nopCommerce","labels_url":"https://api.github.com/repos/nopSolutions/nopCommerce/issues/1905/labels{/name}","comments_url":"https://api.github.com/repos/nopSolutions/nopCommerce/issues/1905/comments","events_url":"https://api.github.com/repos/nopSolutions/nopCommerce/issues/1905/events","html_url":"https://github.com/nopSolutions/nopCommerce/issues/1905","id":192517300,"number":1905,"title":"Remove unuseful dependency register in Nop.Web.Framework/DependencyRegistrar.cs","user":{"login":"JohnsonYuan","id":3370921,"avatar_url":"https://avatars.githubusercontent.com/u/3370921?v=3","gravatar_id":"","url":"https://api.github.com/users/JohnsonYuan","html_url":"https://github.com/JohnsonYuan","followers_url":"https://api.github.com/users/JohnsonYuan/followers","following_url":"https://api.github.com/users/JohnsonYuan/following{/other_user}","gists_url":"https://api.github.com/users/JohnsonYuan/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnsonYuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnsonYuan/subscriptions","organizations_url":"https://api.github.com/users/JohnsonYuan/orgs","repos_url":"https://api.github.com/users/JohnsonYuan/repos","events_url":"https://api.github.com/users/JohnsonYuan/events{/privacy}","received_events_url":"https://api.github.com/users/JohnsonYuan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-30T09:36:48Z","updated_at":"2016-11-30T09:36:48Z","closed_at":null,"body":"In \\Libraries\\Nop.Core\\Caching\\RedisCacheManager.cs, we Resolve ICacheManager without key: \r\n`\r\nthis._perRequestCacheManager = EngineContext.Current.Resolve<ICacheManager>();\r\n`\r\nand we can get \"PerRequestCacheManager\", this is because we register PerRequestCacheManager last.\r\n\r\nIn Nop.Web.Framework/DependencyRegistrar.cs, line 131\r\n`\r\n            //cache managers\r\n            if (config.RedisCachingEnabled)\r\n            {\r\n                builder.RegisterType<RedisConnectionWrapper>().As<IRedisConnectionWrapper>().SingleInstance();\r\n                builder.RegisterType<RedisCacheManager>().As<ICacheManager>().Named<ICacheManager>(\"nop_cache_static\").InstancePerLifetimeScope();\r\n            }\r\n            else\r\n            {\r\n                builder.RegisterType<MemoryCacheManager>().As<ICacheManager>().Named<ICacheManager>(\"nop_cache_static\").SingleInstance();\r\n            }\r\n            builder.RegisterType<PerRequestCacheManager>().As<ICacheManager>().Named<ICacheManager>(\"nop_cache_per_request\").InstancePerLifetimeScope();\r\n`\r\n\r\nbecause last registered wins, so\r\n builder.RegisterType<PerRequestCacheManager>().As<ICacheManager always wins.\r\n\r\nI think we can remove the unuseful Register, \r\nchange \r\n builder.RegisterType<RedisCacheManager>().As<ICacheManager>().Named<ICacheManager>(\"nop_cache_static\").InstancePerLifetimeScope();\r\n\r\nto \r\n\r\n builder.RegisterType<RedisCacheManager>()..Named<ICacheManager>(\"nop_cache_static\").InstancePerLifetimeScope();\r\n\r\nchange\r\n\r\n builder.RegisterType<MemoryCacheManager>().As<ICacheManager>().Named<ICacheManager>(\"nop_cache_static\").SingleInstance();\r\n\r\nto\r\n\r\n builder.RegisterType<MemoryCacheManager>().Named<ICacheManager>(\"nop_cache_static\").SingleInstance();\r\n\r\n"}}
{"actor":{"display_login":"JohnsonYuan"}}