Uncomment the cache settings
This commit is contained in:
		| @@ -3,21 +3,22 @@ | ||||
| //     AgileWebs | ||||
| // </copyright> | ||||
| // *********************************************************************** | ||||
| using Core.Blueprint.Caching.Adapters; | ||||
| using Core.Blueprint.Caching.Contracts; | ||||
| using Core.Blueprint.Caching.Helpers; | ||||
| using Core.Blueprint.Mongo; | ||||
| 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.Thalos.Domain.Contexts.Onboarding.Request; | ||||
| using Core.Thalos.Provider.Contracts; | ||||
| using Mapster; | ||||
| using Microsoft.Extensions.Options; | ||||
| using MongoDB.Driver; | ||||
| using Core.Thalos.Provider.Contracts; | ||||
| using MongoDB.Bson; | ||||
| using System.Text.RegularExpressions; | ||||
| using MongoDB.Bson.Serialization; | ||||
| using Core.Thalos.Domain.Contexts.Onboarding.Request; | ||||
| using Microsoft.Graph; | ||||
| using MongoDB.Bson; | ||||
| using MongoDB.Bson.Serialization; | ||||
| using MongoDB.Driver; | ||||
| using System.ComponentModel.Design; | ||||
| using System.Text.RegularExpressions; | ||||
|  | ||||
| namespace Core.Thalos.Provider.Providers.Onboarding | ||||
| { | ||||
| @@ -27,19 +28,19 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|     public class RoleProvider : IRoleProvider | ||||
|     { | ||||
|         private readonly CollectionRepository<RoleAdapter> repository; | ||||
|         //private readonly CacheSettings cacheSettings; | ||||
|         //private readonly IRedisCacheProvider cacheProvider; | ||||
| 		private readonly CacheSettings cacheSettings; | ||||
| 		private readonly ICacheProvider cacheProvider; | ||||
|  | ||||
|         public RoleProvider(CollectionRepository<RoleAdapter> repository | ||||
|         //IRedisCacheProvider cacheProvider,  | ||||
|         //IOptions<CacheSettings> cacheSettings | ||||
|             ) | ||||
| 		public RoleProvider(CollectionRepository<RoleAdapter> repository, | ||||
| 		    ICacheProvider cacheProvider, | ||||
| 			IOptions<CacheSettings> cacheSettings | ||||
| 			) | ||||
|         { | ||||
|             this.repository = repository; | ||||
|             this.repository.CollectionInitialization(); | ||||
|             //this.cacheSettings = cacheSettings.Value; | ||||
|             //this.cacheProvider = cacheProvider; | ||||
|         } | ||||
| 			this.cacheSettings = cacheSettings.Value; | ||||
| 			this.cacheProvider = cacheProvider; | ||||
| 		} | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Creates a new Role. | ||||
| @@ -64,14 +65,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|         /// the asynchronous execution of the service.</returns> | ||||
|         public async ValueTask<RoleAdapter> GetRoleById(string _id, CancellationToken cancellationToken) | ||||
|         { | ||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetRoleById", _id); | ||||
|             //var cachedData = await cacheProvider.GetAsync<RoleAdapter>(cacheKey); | ||||
|             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetRoleById", _id); | ||||
|             var cachedData = await cacheProvider.GetAsync<RoleAdapter>(cacheKey); | ||||
|  | ||||
|             //if (cachedData is not null) { return cachedData; } | ||||
|             if (cachedData is not null) { return cachedData; } | ||||
|  | ||||
|             var role = await repository.FindByIdAsync(_id); | ||||
|  | ||||
|             //await cacheProvider.SetAsync(cacheKey, role); | ||||
|             await cacheProvider.SetAsync(cacheKey, role); | ||||
|  | ||||
|             return role; | ||||
|         } | ||||
| @@ -83,14 +84,14 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|         /// the asynchronous execution of the service.</returns> | ||||
|         public async ValueTask<IEnumerable<RoleAdapter>> GetAllRoles(CancellationToken cancellationToken) | ||||
|         { | ||||
|             //var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllRoles"); | ||||
|             //var cachedData = await cacheProvider.GetAsync<IEnumerable<RoleAdapter>>(cacheKey) ?? []; | ||||
|             var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllRoles"); | ||||
|             var cachedData = await cacheProvider.GetAsync<IEnumerable<RoleAdapter>>(cacheKey) ?? []; | ||||
|  | ||||
|             //if (cachedData.Any()) return cachedData; | ||||
|             if (cachedData.Any()) return cachedData; | ||||
|  | ||||
|             var roles = await repository.AsQueryable(); | ||||
|  | ||||
|             //await cacheProvider.SetAsync(cacheKey, roles); | ||||
|             await cacheProvider.SetAsync(cacheKey, roles); | ||||
|  | ||||
|             return roles; | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Oscar Morales
					Oscar Morales