EF Core Extension Methods: Caching Options
NCache EF Core Extension Methods provide advanced caching capabilities through the CachingOptions class, enabling granular control over distributed data storage. These options allow developers to enrich cache items before insertion by configuring a QueryIdentifier for result set tracking, establishing Database Dependencies for automatic synchronization, and setting Cache Item Priority. Utilizing these API options ensures high performance and data integrity for Entity Framework Core applications in a clustered environment.
Prerequisites
To utilize the CachingOptions API for EF Core, include the following namespaces in your application:
Configure EF Core Query Identifier and DB Dependency
The following sample configures the cache with the EF Core QueryIdentifier CustomerEntity and creates a DB dependency on the cache items with Absolute Expiration.
var options = new CachingOptions
{
QueryIdentifier = "CustomerEntity",
CreateDbDependency = true,
StoreAs = StoreAs.SeperateEntities,
Priority = Runtime.CacheItemPriority.High
};
options.SetAbsoluteExpiration(DateTime.Now.AddSeconds(20));
See Also
.NET: Alachisoft.NCache.EntityFrameworkCore and Alachisoft.NCache.Runtime.Caching namespaces.