Revert memory cache
This commit is contained in:
		| @@ -1,15 +1,14 @@ | ||||
| using Azure.Identity; | ||||
| using Core.Blueprint.Caching.Contracts; | ||||
| using Microsoft.Extensions.Logging; | ||||
| using StackExchange.Redis; | ||||
| using System.Text.Json; | ||||
|  | ||||
| namespace Core.Blueprint.Caching | ||||
| namespace Core.Blueprint.Redis | ||||
| { | ||||
|     /// <summary> | ||||
|     /// Redis cache provider for managing cache operations. | ||||
|     /// </summary> | ||||
|     public sealed class RedisCacheProvider : ICacheProvider | ||||
|     public sealed class RedisCacheProvider : IRedisCacheProvider | ||||
|     { | ||||
|         private IDatabase _cacheDatabase = null!; | ||||
|         private readonly ILogger<RedisCacheProvider> _logger; | ||||
| @@ -35,29 +34,14 @@ namespace Core.Blueprint.Caching | ||||
|         /// <param name="connectionString">The Redis connection string.</param> | ||||
|         /// <returns>An <see cref="IDatabase"/> instance representing the Redis cache database.</returns> | ||||
|         /// <exception cref="Exception">Thrown when the connection to Redis fails.</exce | ||||
|         public async Task<IDatabase> InitializeRedisAsync(string connectionString) | ||||
|         async Task<IDatabase> InitializeRedisAsync(string connectionString) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty; | ||||
|  | ||||
|                 ConfigurationOptions configurationOptions; | ||||
|  | ||||
|                 if (environment.Equals("Local", StringComparison.OrdinalIgnoreCase)) | ||||
|                 { | ||||
|                     // Use simple local Redis config | ||||
|                     configurationOptions = ConfigurationOptions.Parse(connectionString); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     // Use Azure Redis config | ||||
|                     configurationOptions = await ConfigurationOptions | ||||
|                         .Parse(connectionString) | ||||
|                         .ConfigureForAzureWithTokenCredentialAsync(new DefaultAzureCredential()); | ||||
|                 } | ||||
|                 var configurationOptions = await ConfigurationOptions.Parse($"{connectionString}") | ||||
|                     .ConfigureForAzureWithTokenCredentialAsync(new DefaultAzureCredential()); | ||||
|  | ||||
|                 configurationOptions.AbortOnConnectFail = false; | ||||
|  | ||||
|                 var connectionMultiplexer = await ConnectionMultiplexer.ConnectAsync(configurationOptions); | ||||
|  | ||||
|                 _logger.LogInformation("Successfully connected to Redis."); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user