• Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Try NCache
  • Contact Us
Try NCache
Show / Hide Table of Contents

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

  • .NET
  • Install the following NuGet packages in your client application:
    • NCache: EntityFrameworkCore.NCache
    • NCache Open Source: EntityFrameworkCore.NCache.OpenSource
  • Include the following namespaces in your application:
    • Alachisoft.NCache.EntityFrameworkCore
    • Alachisoft.NCache.Runtime.Caching
  • The cache must be running.
  • Make sure that the data being added is serializable.
  • For API details, refer to: CachingOptions, QueryIdentifier, Priority, CacheItemPriority, CreateDbDependency, StoreAs, SetAbsoluteExpiration.

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.

  • .NET
var options = new CachingOptions
{
    QueryIdentifier = "CustomerEntity",
    CreateDbDependency = true,
    StoreAs = StoreAs.SeparateEntities,
    Priority = Runtime.CacheItemPriority.High
};

options.SetAbsoluteExpiration(DateTime.Now.AddSeconds(20));
Note

To ensure the operation is fail-safe, it is recommended to handle any potential exceptions within your application, as explained in Handling Failures.

See Also

.NET: Alachisoft.NCache.EntityFrameworkCore and Alachisoft.NCache.Runtime.Caching namespaces.

Contact Us

PHONE

+1 214-619-2601   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Try NCache
Pricing
NCache Playground

Deployments
  • Cloud
  • Docker
  • Kubernetes
  • On-Premises
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • SignalR Backplane
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Blogs
  • Foundations
  • Videos
  • Comparisons
  • Shows
  • Whitepapers
  • Articles
  • Tech Talks
  • Magazine Articles
  • Third-Party Articles
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Docs
  • Schedule a Demo
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Terms of Use
  •  
  • Privacy Policy
  •  
  • Cookie Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
  • Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS