Skip to content

Commit

Permalink
fix: redis serializer name
Browse files Browse the repository at this point in the history
  • Loading branch information
Dim145 committed Apr 7, 2024
1 parent 4785991 commit 7100250
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions DatabaseBackupManager/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public static class Constants

public const string DefaultValueForSqliteColumns = "sqlite_default";

public const string RedisCachingName = "BackupManagerRedisPack";

public static readonly string[] AllBackupsFileExtensions = { Core.Constants.PostgresBackupFileExtension, Core.Constants.MySqlBackupFileExtension, Core.Constants.SqlServerBackupFileExtension, Core.Constants.SqliteBackupFileExtension };

internal static void AddOrUpdateHangfireJob(BackupJob backupJob)
Expand Down
3 changes: 2 additions & 1 deletion DatabaseBackupManager/DatabaseBackupManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
<PackageReference Include="AWSSDK.S3" Version="3.7.305.30" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.19.1" />
<PackageReference Include="Cronos" Version="0.8.4" />
<PackageReference Include="EasyCaching.InMemory" Version="1.9.2" />
<PackageReference Include="EasyCaching.Redis" Version="1.9.2" />
<PackageReference Include="EasyCaching.Serialization.Json" Version="1.9.2" />
<PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="4.3.1" />
<PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="4.4.1" />
<PackageReference Include="FluentEmail.Razor" Version="3.0.2" />
<PackageReference Include="FluentEmail.Smtp" Version="3.0.2" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.11" />
Expand Down
22 changes: 12 additions & 10 deletions DatabaseBackupManager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Reflection;
using Azure.Storage;
using Core.Services;
using DatabaseBackupManager;
using DatabaseBackupManager.Authorizations;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -84,6 +85,14 @@ void getOptions(IServiceProvider sp, DbContextOptionsBuilder options)

if (hasRedis)
{
builder.Services.AddEFSecondLevelCache(options =>
{
options.ConfigureLogging(true, tuple => Console.WriteLine(tuple.Item2));
options.UseEasyCachingCoreProvider(Constants.RedisCachingName);
options.CacheAllQueries(CacheExpirationMode.Sliding, TimeSpan.FromMinutes(Seeds.RedisSettings.CacheExpiration));
options.UseDbCallsIfCachingProviderIsDown(TimeSpan.FromSeconds(Seeds.RedisSettings.Timeout));
});

builder.Services.AddEasyCaching(options =>
{
options.UseRedis(config =>
Expand All @@ -92,15 +101,9 @@ void getOptions(IServiceProvider sp, DbContextOptionsBuilder options)
config.DBConfig.Endpoints.Add(new ServerEndPoint(Seeds.RedisSettings.Host, Seeds.RedisSettings.Port));
config.DBConfig.Password = Seeds.RedisSettings.Password;
config.DBConfig.IsSsl = Seeds.RedisSettings.Ssl;
}, "backup-manager-redis-pack")
.WithJson();
});

builder.Services.AddEFSecondLevelCache(options =>
{
options.UseEasyCachingCoreProvider("backup-manager-redis-pack");
options.CacheAllQueries(CacheExpirationMode.Sliding, TimeSpan.FromMinutes(Seeds.RedisSettings.CacheExpiration));
options.UseDbCallsIfCachingProviderIsDown(TimeSpan.FromSeconds(Seeds.RedisSettings.Timeout));
config.SerializerName = Constants.RedisCachingName;
}, Constants.RedisCachingName)
.WithJson(Constants.RedisCachingName);
});
}

Expand Down Expand Up @@ -147,7 +150,6 @@ void getOptions(IServiceProvider sp, DbContextOptionsBuilder options)

builder.Services.AddControllersWithViews();

builder.Services.AddScoped<PostgresBackupService>();
builder.Services.AddScoped<HangfireService>();
builder.Services.AddScoped<LogoutMiddleware>();

Expand Down

0 comments on commit 7100250

Please sign in to comment.