-
Notifications
You must be signed in to change notification settings - Fork 4
Description
PerDbContextCompiledQueryCache makes compiled queries per context, obviously as its name suggests. As @darxis pointed out earlier, ICompiledQueryCache by default is registered as a singleton in EF Core (see _coreServices Dictionary), now it is overridden to be Scoped by LazyLoadingOptionsExtension. In many scenarios, DbContexts are living for just a short time interval, therefore we lose compiled query caching by opening another one, however asking just the same query many times possibly. I haven't ran load tests against this scenario, but won't this affect performance?
Connected issue: in current EF core dev branch CompiledQueryCache accepts only an IMemoryCache parameter in its constructor therefore from the next version, LL won't be able to get the ICurrentDbContext from IDbContextServices parameter anymore (see current CompiledQueryCache.cs).