blob: c4d9ef740e39f18af34ae3a714e1e4a4cfd133bc [file] [log] [blame]
<!--
▄▄▄ ██▓███ ▄▄▄ ▄████▄ ██░ ██ ▓█████ ██▓ ▄████ ███▄ █ ██▓▄▄▄█████▓▓█████
▒████▄ ▓██░ ██▒▒████▄ ▒██▀ ▀█ ▓██░ ██▒▓█ ▀ ▓██▒ ██▒ ▀█▒ ██ ▀█ █ ▓██▒▓ ██▒ ▓▒▓█ ▀
▒██ ▀█▄ ▓██░ ██▓▒▒██ ▀█▄ ▒▓█ ▄ ▒██▀▀██░▒███ ▒██▒▒██░▄▄▄░▓██ ▀█ ██▒▒██▒▒ ▓██░ ▒░▒███
░██▄▄▄▄██ ▒██▄█▓▒ ▒░██▄▄▄▄██ ▒▓▓▄ ▄██▒░▓█ ░██ ▒▓█ ▄ ░██░░▓█ ██▓▓██▒ ▐▌██▒░██░░ ▓██▓ ░ ▒▓█ ▄
▓█ ▓██▒▒██▒ ░ ░ ▓█ ▓██▒▒ ▓███▀ ░░▓█▒░██▓░▒████▒ ░██░░▒▓███▀▒▒██░ ▓██░░██░ ▒██▒ ░ ░▒████▒
▒▒ ▓▒█░▒▓▒░ ░ ░ ▒▒ ▓▒█░░ ░▒ ▒ ░ ▒ ░░▒░▒░░ ▒░ ░ ░▓ ░▒ ▒ ░ ▒░ ▒ ▒ ░▓ ▒ ░░ ░░ ▒░ ░
▒ ▒▒ ░░▒ ░ ▒ ▒▒ ░ ░ ▒ ▒ ░▒░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ▒░ ▒ ░ ░ ░ ░ ░
░ ▒ ░░ ░ ▒ ░ ░ ░░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░ ▒ ░ ░ ░
░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
-->
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="canonical" href="https://ignite.apache.org/use-cases/caching/hibernate-l2-cache.html" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hibernate Second-Level Cache Use Case - Apache Ignite</title>
<!--#include virtual="/includes/styles.html" -->
</head>
<body>
<!--#include virtual="/includes/header.html" -->
<article>
<header>
<div class="container">
<h1 >Second-Level Cache <strong>for Hibernate</strong></h1>
</div>
</header>
<div class="container">
<p>
Hibernate stores data in first-level (L1) cache to minimize expensive database requests. However,
this data is cached per Hibernate session and is not shared among threads. A common solution here is
to configure a second-level (L2) cache.
</p>
<img class="img-responsive diagram-right" src="/images/hibernate-L2-cache.png" alt="Second-Level Cache for Hibernate" />
<p>
Ignite In-Memory Data Grid can be plugged in as Hibernate second-level (L2) cache.
Accessible by all sessions, Ignite Data Grid can significantly accelerate the performance of your
application by reducing the data access time.
</p>
<h2>How Hibernate Caching Works</h2>
<p>
Hibernate first-level (L1) cache is associated with the session object, the scope of which
is limited to a single session. Objects cached in one session are not shared with another,
which means that a request for the same entity by another session
will still go to the database.
</p>
<h2>Ignite as Hibernate L2 Cache</h2>
<p>
To overcome the issue of per-session cache, a global second-level (L2) cache can be configured,
in which cached objects are visible to all sessions. This usually gives a significantly greater
performance gain since each newly created session now has access to the data already present in
the L2 cache memory.
</p>
<p>
Apache Ignite can be plugged-in as Hibernate L2 cache implementation, and can be used in all access
modes - <code>READ_ONLY</code>, <code>READ_WRITE</code>, <code>NONSTRICT_READ_WRITE</code>, and
<code>TRANSACTIONAL</code>, supporting a wide range of related features:
<ul class="page-list">
<li>On-Heap and Off-Heap in-memory stores, as well as disk overflow.</li>
<li>Cache transactions, that make <code>TRANSACTIONAL</code> mode possible.</li>
<li>Clustering, with 2 different replication modes: <code>REPLICATED</code> and <code>PARTITIONED</code></li>
</ul>
</p>
<p>
<a href="https://apacheignite-mix.readme.io/docs/hibernate-l2-cache">
<b>Configure Hibernate L2 Cache <i class="fa fa-angle-double-right"></i></b>
</a>
</p>
</div>
</article>
<!--#include virtual="/includes/footer.html" -->
<!--#include virtual="/includes/scripts.html" -->
</body>
</html>