NHibernate Tour (22): Explore the NHibernate-level cache

Source: Internet
Author: User

The contents of this section

Introduced

NHibernate Level Cache Introduction

NHibernate Level Cache Management

Conclusion

Introduced

Do you guys have a look at the last article? Object state. This can easily extend to the nhibernate cache. We use the NHibernate caching mechanism flexibly in the project. NHibernate performance will be greatly improved oh, we next to explore the NHibernate caching mechanism, this article I do not prepare anything, first to learn the next NHibernate cache.

NHibernate Level Cache Introduction

NHibernate-level cache, ISession cache, ISession cache is a transaction-level cache and is nhibernate built in. The data in the ISession cache is used only within this isession cycle.

You can use the ISession cache after the ISession instance is created. Thereafter, when the ISession instance operates on the data, the built-in cache is queried first, and the cached data is used directly if the corresponding data exists in the ISession cache. If it does not exist, the database is queried and its results are in the cache.

Example 1: Querying a persistent instance[Test]
public void SessionCacheTest()
{
  Customer customer = _transaction.GetCustomerById(1);
}

This is how we normally query a data, NHibernate initialization ISession, the ISession cache does not exist in this data, then nhibernate need to load data from the database.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.