{"action":"created","issue":{"url":"https://api.github.com/repos/VahidN/EFSecondLevelCache.Core/issues/4","repository_url":"https://api.github.com/repos/VahidN/EFSecondLevelCache.Core","labels_url":"https://api.github.com/repos/VahidN/EFSecondLevelCache.Core/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/VahidN/EFSecondLevelCache.Core/issues/4/comments","events_url":"https://api.github.com/repos/VahidN/EFSecondLevelCache.Core/issues/4/events","html_url":"https://github.com/VahidN/EFSecondLevelCache.Core/issues/4","id":221743797,"node_id":"MDU6SXNzdWUyMjE3NDM3OTc=","number":4,"title":"It dosen't work in my application","user":{"login":"fishen","id":17705466,"node_id":"MDQ6VXNlcjE3NzA1NDY2","avatar_url":"https://avatars3.githubusercontent.com/u/17705466?v=4","gravatar_id":"","url":"https://api.github.com/users/fishen","html_url":"https://github.com/fishen","followers_url":"https://api.github.com/users/fishen/followers","following_url":"https://api.github.com/users/fishen/following{/other_user}","gists_url":"https://api.github.com/users/fishen/gists{/gist_id}","starred_url":"https://api.github.com/users/fishen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fishen/subscriptions","organizations_url":"https://api.github.com/users/fishen/orgs","repos_url":"https://api.github.com/users/fishen/repos","events_url":"https://api.github.com/users/fishen/events{/privacy}","received_events_url":"https://api.github.com/users/fishen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-04-14T05:19:17Z","updated_at":"2018-08-01T08:41:30Z","closed_at":"2017-04-14T06:51:17Z","author_association":"NONE","body":"I used redis as cache provider but it dosen't work,  i can't find any key in redis db,\r\nso I switched to another model(WithMicrosoftMemoryCacheHandle),  It does not seem to work too.\r\nI wrote two action for compare cache and nocache, but the time-consuming seems almost.\r\nI need your help @VahidN .\r\n```\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            services.AddSingleton<IConfigurationRoot>(provider => { return Configuration; });\r\n            services.AddDbContext<SinoautoContext>(ServiceLifetime.Scoped);\r\n            // Add framework services.\r\n            var redisConnStr = Configuration.GetConnectionString(\"RedisConnetionString\");\r\n            var redisConn = ConnectionMultiplexer.Connect(redisConnStr);\r\n            \r\n            services.AddEFSecondLevelCache();\r\n            services.AddSingleton(typeof(ICacheManager<>), typeof(BaseCacheManager<>));\r\n            services.AddSingleton(typeof(ICacheManagerConfiguration),\r\n                new CacheManager.Core.ConfigurationBuilder()\r\n                    .WithJsonSerializer()\r\n                    //.WithRedisConfiguration(\"Redis\", redisConn)\r\n                    //.WithRedisCacheHandle(\"Redis\")\r\n                    .WithMicrosoftMemoryCacheHandle()\r\n                    .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromSeconds(10))\r\n                    .Build()\r\n            );\r\n            services.AddMvc();\r\n        }\r\n\r\n        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.\r\n        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)\r\n        {\r\n            loggerFactory.AddConsole(Configuration.GetSection(\"Logging\"));\r\n            loggerFactory.AddDebug();\r\n            app.UseEFSecondLevelCache();\r\n            app.UseMvc();\r\n        }\r\n```\r\n```\r\n        [HttpGet]\r\n        public IActionResult Get()\r\n        {\r\n            var list = db.HttpLogs.Take(1000).ToList();\r\n            return Json(list);\r\n        }\r\n\r\n        [HttpGet(\"cache\")]\r\n        public IActionResult GetByCache()\r\n        {\r\n            var list = db.HttpLogs.Take(1000).Cacheable().ToList();\r\n            return Json(list);\r\n        }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/VahidN/EFSecondLevelCache.Core/issues/comments/409498464","html_url":"https://github.com/VahidN/EFSecondLevelCache.Core/issues/4#issuecomment-409498464","issue_url":"https://api.github.com/repos/VahidN/EFSecondLevelCache.Core/issues/4","id":409498464,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTQ5ODQ2NA==","user":{"login":"attiqeurrehman","id":1382615,"node_id":"MDQ6VXNlcjEzODI2MTU=","avatar_url":"https://avatars2.githubusercontent.com/u/1382615?v=4","gravatar_id":"","url":"https://api.github.com/users/attiqeurrehman","html_url":"https://github.com/attiqeurrehman","followers_url":"https://api.github.com/users/attiqeurrehman/followers","following_url":"https://api.github.com/users/attiqeurrehman/following{/other_user}","gists_url":"https://api.github.com/users/attiqeurrehman/gists{/gist_id}","starred_url":"https://api.github.com/users/attiqeurrehman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/attiqeurrehman/subscriptions","organizations_url":"https://api.github.com/users/attiqeurrehman/orgs","repos_url":"https://api.github.com/users/attiqeurrehman/repos","events_url":"https://api.github.com/users/attiqeurrehman/events{/privacy}","received_events_url":"https://api.github.com/users/attiqeurrehman/received_events","type":"User","site_admin":false},"created_at":"2018-08-01T08:41:29Z","updated_at":"2018-08-01T08:41:29Z","author_association":"NONE","body":"@VahidN I am having the same trouble. I have checked with the `debugInfo.IsCacheHit` and it returns false even after numerous times. \r\n\r\nFollowing is my configuration:\r\n\r\n```c#\r\npublic IServiceProvider ConfigureServices(IServiceCollection services)\r\n{\r\n       // Other code is stripped for clarity\r\n      // Add Redis cache service provider\r\n      services.AddEFSecondLevelCache();\r\n      AddRedisCacheServiceProvider(services);\r\n}\r\n\r\nprivate static void AddRedisCacheServiceProvider(IServiceCollection services)\r\n        {\r\n            var jss = new JsonSerializerSettings\r\n            {\r\n                NullValueHandling = NullValueHandling.Ignore,\r\n                ReferenceLoopHandling = ReferenceLoopHandling.Ignore\r\n            };\r\n\r\n            const string redisConfigurationKey = \"redis\";\r\n            services.AddSingleton(typeof(ICacheManagerConfiguration),\r\n                new CacheManager.Core.ConfigurationBuilder()\r\n                    .WithJsonSerializer(jss, jss)\r\n                    .WithUpdateMode(CacheUpdateMode.Up)\r\n                    .WithRedisConfiguration(redisConfigurationKey, config =>\r\n                    {\r\n                        config.WithAllowAdmin()\r\n                            .WithDatabase(0)\r\n                            .WithEndpoint(\"localhost\", 6379);\r\n                    })\r\n                    .WithMaxRetries(100)\r\n                    .WithRetryTimeout(50)\r\n                    .WithRedisCacheHandle(redisConfigurationKey)\r\n                    .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromMinutes(10))\r\n                    .Build());\r\n            services.AddSingleton(typeof(ICacheManager<>), typeof(BaseCacheManager<>));\r\n        }\r\n\r\npublic void Configure(IApplicationBuilder app, IHostingEnvironment env)\r\n        {\r\n            app.UseEFSecondLevelCache();\r\n            //other code is stripped for clarity \r\n        }\r\n```\r\n\r\nFollowing code is to get the the list of objects:\r\n\r\n```c#\r\nprotected override async Task<object> OnHandleAsync(RestGetListRequest<TEntity, TGetModel> message,\r\n            CancellationToken cancellationToken)\r\n        {\r\n            var results = UnitOfWork.GetRepository<TEntity>().GetAll();\r\n var debugInfo = new EFCacheDebugInfo();\r\n            var mapped = await results.Cacheable(debugInfo).ProjectTo<TGetModel>(Mapper.ConfigurationProvider)\r\n                    .ToArrayAsync(cancellationToken);\r\n            return mapped;\r\n        }\r\n```\r\nDbContext is overriding the following:\r\n\r\n```c#\r\npublic override int SaveChanges()\r\n        {\r\n            ChangeTracker.DetectChanges();\r\n            var changedEntityNames = this.GetChangedEntityNames();\r\n\r\n            ChangeTracker.AutoDetectChangesEnabled = false; // for performance reasons, to avoid calling DetectChanges() again.\r\n            var result = base.SaveChanges();\r\n            ChangeTracker.AutoDetectChangesEnabled = true;\r\n\r\n            this.GetService<IEFCacheServiceProvider>().InvalidateCacheDependencies(changedEntityNames);\r\n\r\n            return result;\r\n        }\r\n\r\n        public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())\r\n        {\r\n            ChangeTracker.DetectChanges();\r\n            var changedEntityNames = this.GetChangedEntityNames();\r\n\r\n            ChangeTracker.AutoDetectChangesEnabled = false; // for performance reasons, to avoid calling DetectChanges() again.\r\n            var result = base.SaveChangesAsync(cancellationToken);\r\n            ChangeTracker.AutoDetectChangesEnabled = true;\r\n\r\n            this.GetService<IEFCacheServiceProvider>().InvalidateCacheDependencies(changedEntityNames);\r\n\r\n            return result;\r\n        }\r\n```\r\n\r\nBase class library responsible for getting the results is using the following:\r\n\r\n```xml\r\n<Project Sdk=\"Microsoft.NET.Sdk\">\r\n    <PropertyGroup>\r\n        <TargetFramework>netstandard2.0</TargetFramework>\r\n    </PropertyGroup>\r\n    <ItemGroup>\r\n        <PackageReference Include=\"Autofac\" Version=\"4.8.1\" />\r\n        <PackageReference Include=\"Autofac.Extensions.DependencyInjection\" Version=\"4.2.2\" />\r\n        <PackageReference Include=\"AutoMapper\" Version=\"7.0.1\" />\r\n        <PackageReference Include=\"AutoMapper.Attributes\" Version=\"6.0.1\" />\r\n        <PackageReference Include=\"EFSecondLevelCache.Core\" Version=\"1.6.1\" />\r\n        <PackageReference Include=\"EntityFrameworkCore.Triggers\" Version=\"1.1.1\" />\r\n        <PackageReference Include=\"FluentValidation\" Version=\"7.6.104\" />\r\n        <PackageReference Include=\"MediatR\" Version=\"5.0.1\" />\r\n        <PackageReference Include=\"Microsoft.EntityFrameworkCore\" Version=\"2.1.1\" />\r\n        <PackageReference Include=\"Microsoft.AspNetCore.Mvc\" Version=\"2.1.1\" />\r\n        <PackageReference Include=\"Microsoft.EntityFrameworkCore.UnitOfWork\" Version=\"2.0.4\" />\r\n    </ItemGroup>\r\n</Project>\r\n```\r\n\r\nand ASP.NET Core Web API is using the following:\r\n\r\n```xml\r\n<ItemGroup>\r\n    <PackageReference Include=\"EFSecondLevelCache.Core\" Version=\"1.6.0\" />\r\n    <PackageReference Include=\"CacheManager.Core\" Version=\"1.1.2\" />\r\n    <PackageReference Include=\"CacheManager.Microsoft.Extensions.Caching.Memory\" Version=\"1.1.2\" />\r\n    <PackageReference Include=\"CacheManager.StackExchange.Redis\" Version=\"1.1.2\" />\r\n    <PackageReference Include=\"CacheManager.Serialization.Json\" Version=\"1.1.2\" />\r\n  </ItemGroup>\r\n```\r\n\r\nWhat am I missing here?\r\n\r\n"}}
{"actor":{"display_login":"attiqeurrehman"}}