EF Core Extension Methods : Caching Options
Note
This feature is available in NCache Enterprise and Professional.
Using the EF Core Extension Methods allows you to use some integral caching features provided by NCache. These caching options are encapsulated in the CachingOptions class provided by the EF Core Extension Methods. These caching options are used to populate the cache item before inserting it into the cache. These include a Query Identifier against the query result set, creating a DB dependency, and so on.
To utilize the CachingOptions API, include the following namespaces in your application:
The following sample configures the cache with the Query identifier CustomerEntity, and creates a DB dependency on the cache items with Absolute Expiration.
Note
Database Dependency is only available in NCache Enterprise .
var options = new CachingOptions
{
QueryIdentifier = "CustomerEntity",
CreateDbDependency = true,
StoreAs = StoreAs.SeperateEntities,
Priority = Runtime.CacheItemPriority.High
};
options.SetAbsoluteExpiration(DateTime.Now.AddSeconds(20));
See Also
EF Core Caching Extension Methods
Cache Handle from EF Core Context
Query Deferred APIs for EF Core Caching
Logging Entity Framework Core Caching