Kaulk.EntityFramework.Cache
2.0.0
dotnet add package Kaulk.EntityFramework.Cache --version 2.0.0
NuGet\Install-Package Kaulk.EntityFramework.Cache -Version 2.0.0
<PackageReference Include="Kaulk.EntityFramework.Cache" Version="2.0.0" />
paket add Kaulk.EntityFramework.Cache --version 2.0.0
#r "nuget: Kaulk.EntityFramework.Cache, 2.0.0"
// Install Kaulk.EntityFramework.Cache as a Cake Addin #addin nuget:?package=Kaulk.EntityFramework.Cache&version=2.0.0 // Install Kaulk.EntityFramework.Cache as a Cake Tool #tool nuget:?package=Kaulk.EntityFramework.Cache&version=2.0.0
Second Level Cache for Entity Framework 6.1+
Entity Framework does not currently support caching of query results. A sample EF Caching provider is available for Entity Framework version 5 and earlier but due to changes to the provider model this sample provider does not work with Entity Framework 6 and newer. This project is filling the gap by enabling caching of query results for Entity Framework 6.1+ applications.
This project was moved from https://efcache.codeplex.com
You may still find some useful information there:
- Old discussion board - https://efcache.codeplex.com/discussions
- Issues - https://efcache.codeplex.com/workitem/list/basic
How to get it
You can get it from NuGet - just install the EntityFramework.Cache NuGet package
How to use it
The project uses a combination of a wrapping provider and a transaction interceptor. A simple InMemoryCache is included in the project. To use it you need first configure EF using code based configuration. Here is an example of how such a configuration looks like.
public class Configuration : DbConfiguration
{
public Configuration()
{
var transactionHandler = new CacheTransactionHandler(new InMemoryCache());
AddInterceptor(transactionHandler);
var cachingPolicy = new CachingPolicy();
Loaded +=
(sender, args) => args.ReplaceService<DbProviderServices>(
(s, _) => new CachingProviderServices(s, transactionHandler,
cachingPolicy));
}
}
Starting with version 1.1.1 you can also use the new static EntityFrameworkCache.Initialize()
method to configure EF to use EFCache. The Initialize
method should be invoked at app startup (before EF is used) - e.g. in the application static constructor. To initialize EFCache with the built-in InMemoryCache you can use the following code:
EntityFrameworkCache.Initialize(new InMemoryCache());
You can find more details in my blogpost
Disclaimer
I am providing code in the repository to you under an open source license. Because this is my personal repository, the license you receive to my code is from me and not my employer (Facebook)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6
- EntityFramework (>= 6.3.0)
-
.NETStandard 2.1
- EntityFramework (>= 6.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 197 | 8/4/2023 |
Support changing of caching strategy.
Added generic caching interface ICacheProvider.