Apply cache configuration
This commit is contained in:
		| @@ -11,8 +11,8 @@ | ||||
|   </ItemGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Blueprint.Mongo" Version="0.0.5" /> | ||||
|     <PackageReference Include="Blueprint.Redis" Version="0.0.1" /> | ||||
|     <PackageReference Include="Blueprint.Mongo" Version="0.0.8" /> | ||||
|     <PackageReference Include="Blueprint.Redis" Version="0.0.4" /> | ||||
|     <PackageReference Include="BuildingBlocks.Library" Version="0.0.1" /> | ||||
|     <PackageReference Include="Mapster" Version="7.4.2-pre02" /> | ||||
|   </ItemGroup> | ||||
|   | ||||
| @@ -5,13 +5,15 @@ | ||||
| // *********************************************************************** | ||||
| using Core.Thalos.Adapters; | ||||
| using Core.Blueprint.Mongo; | ||||
| using Core.Blueprint.Redis; | ||||
| using Core.Blueprint.Redis.Helpers; | ||||
| using Core.Blueprint.Caching; | ||||
| using Core.Blueprint.Caching.Helpers; | ||||
| using Mapster; | ||||
| using Microsoft.Extensions.Options; | ||||
| using MongoDB.Driver; | ||||
| using Core.Thalos.Provider.Contracts; | ||||
| using Core.Thalos.Domain.Contexts.Onboarding.Request; | ||||
| using Core.Blueprint.Caching.Contracts; | ||||
| using Core.Blueprint.Caching.Adapters; | ||||
|  | ||||
| namespace Core.Thalos.Provider.Providers.Onboarding | ||||
| { | ||||
| @@ -22,14 +24,16 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|     { | ||||
|         private readonly CollectionRepository<ModuleAdapter> repository; | ||||
|         private readonly CacheSettings cacheSettings; | ||||
|         //private readonly IRedisCacheProvider cacheProvider; | ||||
|         private readonly ICacheProvider cacheProvider; | ||||
|  | ||||
|         public ModuleProvider(CollectionRepository<ModuleAdapter> repository, IOptions<CacheSettings> cacheSettings) | ||||
|         public ModuleProvider(CollectionRepository<ModuleAdapter> repository, | ||||
|             ICacheProvider cacheProvider, | ||||
|             IOptions<CacheSettings> cacheSettings) | ||||
|         { | ||||
|             this.repository = repository; | ||||
|             this.repository.CollectionInitialization(); | ||||
|             this.cacheSettings = cacheSettings.Value; | ||||
|             //this.cacheProvider = cacheProvider; | ||||
|             this.cacheProvider = cacheProvider; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
| @@ -56,13 +60,13 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|         public async ValueTask<ModuleAdapter> GetModuleById(string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetModuleById", _id); | ||||
|             //var cachedData = await cacheProvider.GetAsync<ModuleAdapter>(cacheKey); | ||||
|             var cachedData = await cacheProvider.GetAsync<ModuleAdapter>(cacheKey); | ||||
|  | ||||
|             //if (cachedData is not null) { return cachedData; } | ||||
|             if (cachedData is not null) { return cachedData; } | ||||
|  | ||||
|             var module = await repository.FindByIdAsync(_id); | ||||
|  | ||||
|             //await cacheProvider.SetAsync(cacheKey, module); | ||||
|             await cacheProvider.SetAsync(cacheKey, module); | ||||
|  | ||||
|             return module; | ||||
|         } | ||||
| @@ -75,13 +79,13 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|         public async ValueTask<IEnumerable<ModuleAdapter>> GetAllModules(CancellationToken cancellationToken) | ||||
|         { | ||||
|             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetModules"); | ||||
|             //var cachedData = await cacheProvider.GetAsync<IEnumerable<ModuleAdapter>>(cacheKey) ?? []; | ||||
|             var cachedData = await cacheProvider.GetAsync<IEnumerable<ModuleAdapter>>(cacheKey) ?? []; | ||||
|  | ||||
|             //if (cachedData.Any()) return cachedData; | ||||
|             if (cachedData.Any()) return cachedData; | ||||
|  | ||||
|             var modules = await repository.AsQueryable(); | ||||
|  | ||||
|             //await cacheProvider.SetAsync(cacheKey, modules); | ||||
|             await cacheProvider.SetAsync(cacheKey, modules); | ||||
|  | ||||
|             return modules; | ||||
|         } | ||||
| @@ -96,9 +100,9 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|         { | ||||
|             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllModulesByList", modules); | ||||
|  | ||||
|             //var cachedData = await cacheProvider.GetAsync<IEnumerable<ModuleAdapter>>(cacheKey) ?? []; | ||||
|             var cachedData = await cacheProvider.GetAsync<IEnumerable<ModuleAdapter>>(cacheKey) ?? []; | ||||
|  | ||||
|             //if (cachedData.Any()) return cachedData; | ||||
|             if (cachedData.Any()) return cachedData; | ||||
|  | ||||
|             var builder = Builders<ModuleAdapter>.Filter; | ||||
|             var filters = new List<FilterDefinition<ModuleAdapter>>(); | ||||
| @@ -112,7 +116,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|  | ||||
|             var modulesList = await repository.FilterByMongoFilterAsync(finalFilter); | ||||
|  | ||||
|             //await cacheProvider.SetAsync(cacheKey, modulesList); | ||||
|             await cacheProvider.SetAsync(cacheKey, modulesList); | ||||
|  | ||||
|             return modulesList; | ||||
|         } | ||||
|   | ||||
| @@ -5,8 +5,8 @@ | ||||
| // *********************************************************************** | ||||
| using Core.Thalos.Adapters; | ||||
| using Core.Blueprint.Mongo; | ||||
| using Core.Blueprint.Redis; | ||||
| using Core.Blueprint.Redis.Helpers; | ||||
| //using Core.Blueprint.Redis; | ||||
| //using Core.Blueprint.Redis.Helpers; | ||||
| using Mapster; | ||||
| using Microsoft.Extensions.Options; | ||||
| using MongoDB.Driver; | ||||
| @@ -21,16 +21,17 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|     public class PermissionProvider : IPermissionProvider | ||||
|     { | ||||
|         private readonly CollectionRepository<PermissionAdapter> repository; | ||||
|         private readonly CacheSettings cacheSettings; | ||||
|         //private readonly CacheSettings cacheSettings; | ||||
|         //private readonly IRedisCacheProvider cacheProvider; | ||||
|  | ||||
|         public PermissionProvider(CollectionRepository<PermissionAdapter> repository, | ||||
|         public PermissionProvider(CollectionRepository<PermissionAdapter> repository | ||||
|         //IRedisCacheProvider cacheProvider,  | ||||
|         IOptions<CacheSettings> cacheSettings) | ||||
|         //IOptions<CacheSettings> cacheSettings | ||||
|             ) | ||||
|         { | ||||
|             this.repository = repository; | ||||
|             this.repository.CollectionInitialization(); | ||||
|             this.cacheSettings = cacheSettings.Value; | ||||
|             //this.cacheSettings = cacheSettings.Value; | ||||
|             //this.cacheProvider = cacheProvider; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -6,8 +6,8 @@ | ||||
| using Core.Thalos.Adapters; | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using Core.Blueprint.Mongo; | ||||
| using Core.Blueprint.Redis; | ||||
| using Core.Blueprint.Redis.Helpers; | ||||
| //using Core.Blueprint.Redis; | ||||
| //using Core.Blueprint.Redis.Helpers; | ||||
| using Mapster; | ||||
| using Microsoft.Extensions.Options; | ||||
| using MongoDB.Driver; | ||||
| @@ -27,16 +27,17 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|     public class RoleProvider : IRoleProvider | ||||
|     { | ||||
|         private readonly CollectionRepository<RoleAdapter> repository; | ||||
|         private readonly CacheSettings cacheSettings; | ||||
|         //private readonly CacheSettings cacheSettings; | ||||
|         //private readonly IRedisCacheProvider cacheProvider; | ||||
|  | ||||
|         public RoleProvider(CollectionRepository<RoleAdapter> repository, | ||||
|         public RoleProvider(CollectionRepository<RoleAdapter> repository | ||||
|         //IRedisCacheProvider cacheProvider,  | ||||
|         IOptions<CacheSettings> cacheSettings) | ||||
|         //IOptions<CacheSettings> cacheSettings | ||||
|             ) | ||||
|         { | ||||
|             this.repository = repository; | ||||
|             this.repository.CollectionInitialization(); | ||||
|             this.cacheSettings = cacheSettings.Value; | ||||
|             //this.cacheSettings = cacheSettings.Value; | ||||
|             //this.cacheProvider = cacheProvider; | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -7,8 +7,8 @@ | ||||
| using Core.Thalos.Adapters; | ||||
| using Core.Thalos.Adapters.Common.Enums; | ||||
| using Core.Blueprint.Mongo; | ||||
| using Core.Blueprint.Redis; | ||||
| using Core.Blueprint.Redis.Helpers; | ||||
| //using Core.Blueprint.Redis; | ||||
| //using Core.Blueprint.Redis.Helpers; | ||||
| using Mapster; | ||||
| using Microsoft.Extensions.Options; | ||||
| using MongoDB.Driver; | ||||
| @@ -25,16 +25,17 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|     public class UserProvider : IUserProvider | ||||
|     { | ||||
|         private readonly CollectionRepository<UserAdapter> repository; | ||||
|         private readonly CacheSettings cacheSettings; | ||||
|         //private readonly CacheSettings cacheSettings; | ||||
|         //private readonly IRedisCacheProvider cacheProvider; | ||||
|  | ||||
|         public UserProvider(CollectionRepository<UserAdapter> repository, | ||||
|         public UserProvider(CollectionRepository<UserAdapter> repository | ||||
|         //IRedisCacheProvider cacheProvider,  | ||||
|         IOptions<CacheSettings> cacheSettings) | ||||
|         //IOptions<CacheSettings> cacheSettings | ||||
|             ) | ||||
|         { | ||||
|             this.repository = repository; | ||||
|             this.repository.CollectionInitialization(); | ||||
|             this.cacheSettings = cacheSettings.Value; | ||||
|             //this.cacheSettings = cacheSettings.Value; | ||||
|             //this.cacheProvider = cacheProvider; | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales