Simple example of write-behind cache

classic Classic list List threaded Threaded
4 messages Options
Kobe Kobe
Reply | Threaded
Open this post in threaded view
|

Simple example of write-behind cache


I am looking for a simple illustration of using Ignite as a write-behind cache with Hibernate (on
Oracle, not that that matters). What I have is this:

   <application> ==  < Hibernate> === <Oracle JDBC>

I am looking to doing this:

   <application> ==  <Ignite cache> === < Hibernate> === <Oracle JDBC>


I have looked through the example but am unable to find it. I do see datagrid example -

thanx,

/Kobe
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Simple example of write-behind cache

Hi Kobe,

Take a look at this example: https://github.com/apache/ignite/tree/master/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate

Sounds like that's exactly what you need.

-Val
Kobe Kobe
Reply | Threaded
Open this post in threaded view
|

Re: Simple example of write-behind cache

Val,

Could you tell me how this works? Is this like a L2 cache for Hibernate?
How is cache coherence maintained? Using Hibernate session listener alone?

Thanx,

/Kobe

vkulichenko wrote
Hi Kobe,

Take a look at this example: https://github.com/apache/ignite/tree/master/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/store/hibernate

Sounds like that's exactly what you need.

-Val
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Simple example of write-behind cache

Kobe,

No, this is a persistence store [1] implemented using Hibernate. When the cache is updated, it will use Hibernate session to update the database. In case of write-through consistency is guaranteed automatically by Ignite (if cache update fails, it will not update the database, and other way around). If there is a transaction, you can use CacheStoreSession and CacheHibernateStoreSessionListener to maintain ongoing Hibernate transaction and commit it only when the cache transaction is committed (this is also demonstrated in the example).

L2 cache is also supported [2], but in this case Ignite is plugged into Hibernate and you use Hibernate API to do updates and reads.

[1] https://apacheignite.readme.io/docs/persistent-store
[2] https://apacheignite.readme.io/docs/hibernate-l2-cache

-Val