Try Playground
Show / Hide Table of Contents

NHibernate Cache

NHibernate is an open-source object-relational mapping solution that provides a framework for mapping relational databases on the object-oriented representation of data - significantly reducing developer efforts in retrieving data from the database. Furthermore, to improve application performance and reduce the load on the database, NHibernate provides NHibernate Cache to reduce repetitive database calls.

Note

This feature is also available in NCache Professional.

First-level NHibernate Cache

NHibernate's first-level caching module provides session-level, in-process caching. Upon session creation, it associates with a session cache. Further, when an object loads from the database, the session cache maintains an object copy. If the same session fetches the object again, it receives a cached copy. In a particular transaction, if the same object is updated multiple times, it is only updated in the session cache. Upon committing the transaction, only the final state of an object is persisted in the database, thus avoiding repetitive update calls.

NHibernate First-Level Cache

NCache as NHibernate Second-level Cache

NCache provides NHibernate Second-level Cache Provider. The NCache Provider configures as an NHibernate Second-level Cache without any code change. Using NCache as a Second-level Cache for NHibernate enables the application to use NCache's distributed caching features.

NCache as NHibernate Second-level Cache

NCache provides the following features with Second-level Cache Provider:

  • Specify Multiple Regions

    Multiple NHibernate regions can be specified and configured in the NCache configuration file for NHibernate Cache. These regions are identified using region names and can be configured with multiple NCache features. Each region can be configured with NCache caching features.

  • NCache Cache for Region

    NCache allows specifying separate cache instances for each region, or one cache instance is used across multiple locations if necessary.

    1. Cache item priority: Data in each region is configured to have a priority in the NHibernate cache. This priority is then used for data eviction policies.

    2. Absolute expiration: Regions can use NCache's Absolute Expiration feature to keep data in the cache up-to-date by expiring old data after the configured time interval.

    3. Sliding expiration: Regions can use NCache's Sliding Expiration feature to keep the most frequently used data while removing the unused data after a specific time interval.

  • Configure Multiple Regions on a Single NCache Cache Instance

    NCache Provider for NHibernate allows using a single NCache instance for multiple NHibernate cache instances. NCache keeps a record of data and its associated NHibernate region.

  • Database Dependencies

    To ensure data consistency with the database, NCache provides a Database Dependency feature for NHibernate applications that can be configured on an entity basis. The Database Dependency synchronizes the cache data with the database such that any change in the database record invalidates the respective entity in the cache. Thus, NHibernate retrieves up-to-date records even if the database update comes from an application other than the NHibernate application.

  • Query Caching Feature to Cache Large Query Results

    Complex and large queries, if executed repeatedly with no result changed, can stress the database. To avoid multiple execution of such queries, NCache allows caching such queries using NHibernate's query cache feature. So, such a query and its results are executed for one NHibernate application and becomes available to all NHibernate applications using that database without querying it.

  • No Code Change Required

    NCache allows the use of all features through its configuration files with no code changes necessary.

In This Section

Using NCache as NHibernate Second-level Cache
Explains how to configure and use NCache as NHibernate Second-level Cache.

Query Caching with NHibernate
Explains how to cache queries in NCache using NHibernate.

Synchronize Database with NHIbernate Second-level Cache
Explains how to synchronize databases with NHibernate in NCache.

In This Article
  • First-level NHibernate Cache
  • NCache as NHibernate Second-level Cache
  • In This Section

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Professional
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

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

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - 2025. All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top