Configuring Ignite caching 

Our RESTful service makes a database call to fetch the player data. You can see the formatted SQL join logs in the Eclipse console, but we can configure a Hibernate query and L2 caching in an Apache Ignite cache. It will bypass the database and return the response from the cache. 

Hibernate supports three levels of caching:

  • 1st level cache: 1st level or session caching is enabled by default. Every database request goes through the JVM level session cache; if the requested object is stored in the session cache, then that object is returned.
  • 2nd level cache: Hibernate supports additional 2nd level caching in a cache store. You need to configure Hibernate properties to enable the 2nd level cache. It stores key-value pairs in a cache store, such as in ehCache or Apache Ignite. The key is the object's id (annotated with @Id) and the value is the object itself. The L2 cache spans between sessions; when you query an object by its id, then hibernate looks up the L2 cache by the object's id and then returns the object, and queries the database if the object is not found in the cache.
  • 3rd level cache: The L2 cache can be used only for object id lookup, but it doesn't store the query results, such as when you execute a SQL query to get all the names where 'John' word is present in the record-"where name like 'John'". The  3rd level Hibernate query cache lets you store the results of the query in a cache store.

We will configure our spring boot app to store hibernate query results in the Apache Ignite cache.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.74.25