From 22d8528d904e69a8e22ba0e6d43dcb58a54bdcf5 Mon Sep 17 00:00:00 2001 From: gnattu Date: Mon, 5 Aug 2024 10:58:22 -0400 Subject: Backport pull request #11901 from jellyfin/release-10.9.z Implement Device Cache to replace EFCoreSecondLevelCacheInterceptor Original-merge: b7bc0e1c96553675a490c0bd92a58ad9c5f0d0e1 Merged-by: joshuaboniface Backported-by: Bond_009 --- .../Extensions/ServiceCollectionExtensions.cs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs') diff --git a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs index a88989840..ff29d69b4 100644 --- a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs +++ b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using EFCoreSecondLevelCacheInterceptor; using MediaBrowser.Common.Configuration; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; @@ -16,28 +15,13 @@ public static class ServiceCollectionExtensions /// Adds the interface to the service collection with second level caching enabled. /// /// An instance of the interface. - /// Whether second level cache disabled.. /// The updated service collection. - public static IServiceCollection AddJellyfinDbContext(this IServiceCollection serviceCollection, bool disableSecondLevelCache) + public static IServiceCollection AddJellyfinDbContext(this IServiceCollection serviceCollection) { - if (!disableSecondLevelCache) - { - serviceCollection.AddEFSecondLevelCache(options => - options.UseMemoryCacheProvider() - .CacheAllQueries(CacheExpirationMode.Sliding, TimeSpan.FromMinutes(10)) - .UseCacheKeyPrefix("EF_") - // Don't cache null values. Remove this optional setting if it's not necessary. - .SkipCachingResults(result => result.Value is null or EFTableRows { RowsCount: 0 })); - } - serviceCollection.AddPooledDbContextFactory((serviceProvider, opt) => { var applicationPaths = serviceProvider.GetRequiredService(); - var dbOpt = opt.UseSqlite($"Filename={Path.Combine(applicationPaths.DataPath, "jellyfin.db")}"); - if (!disableSecondLevelCache) - { - dbOpt.AddInterceptors(serviceProvider.GetRequiredService()); - } + opt.UseSqlite($"Filename={Path.Combine(applicationPaths.DataPath, "jellyfin.db")}"); }); return serviceCollection; -- cgit v1.2.3