mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-04 03:27:21 -05:00 
			
		
		
		
	Implement Device Cache to replace EFCoreSecondLevelCacheInterceptor Original-merge: b7bc0e1c96553675a490c0bd92a58ad9c5f0d0e1 Merged-by: joshuaboniface <joshua@boniface.me> Backported-by: Bond_009 <bond.009@outlook.com>
		
			
				
	
	
		
			30 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.IO;
 | 
						|
using MediaBrowser.Common.Configuration;
 | 
						|
using Microsoft.EntityFrameworkCore;
 | 
						|
using Microsoft.Extensions.DependencyInjection;
 | 
						|
 | 
						|
namespace Jellyfin.Server.Implementations.Extensions;
 | 
						|
 | 
						|
/// <summary>
 | 
						|
/// Extensions for the <see cref="IServiceCollection"/> interface.
 | 
						|
/// </summary>
 | 
						|
public static class ServiceCollectionExtensions
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// Adds the <see cref="IDbContextFactory{TContext}"/> interface to the service collection with second level caching enabled.
 | 
						|
    /// </summary>
 | 
						|
    /// <param name="serviceCollection">An instance of the <see cref="IServiceCollection"/> interface.</param>
 | 
						|
    /// <returns>The updated service collection.</returns>
 | 
						|
    public static IServiceCollection AddJellyfinDbContext(this IServiceCollection serviceCollection)
 | 
						|
    {
 | 
						|
        serviceCollection.AddPooledDbContextFactory<JellyfinDbContext>((serviceProvider, opt) =>
 | 
						|
        {
 | 
						|
            var applicationPaths = serviceProvider.GetRequiredService<IApplicationPaths>();
 | 
						|
            opt.UseSqlite($"Filename={Path.Combine(applicationPaths.DataPath, "jellyfin.db")}");
 | 
						|
        });
 | 
						|
 | 
						|
        return serviceCollection;
 | 
						|
    }
 | 
						|
}
 |