Caching fundamentals (Web hosting resellers) ated with EntityManagers of a particular

Caching fundamentals ated with EntityManagers of a particular persistence unit) share the same second- level cache. Persistent instances are stored in the second-level cache in a disassembled form. Think of disassembly as a process a bit like serialization (the algorithm is much, much faster than Java serialization, however). The internal implementation of this process/cluster scope cache isn t of much interest. More important is the correct usage of the cache policies caching strategies and physical cache providers. Different kinds of data require different cache policies: The ratio of reads to writes varies, the size of the database tables varies, and some tables are shared with other external applications. The second-level cache is configurable at the granularity of an individual class or collection role. This lets you, for example, enable the second-level cache for reference data classes and disable it for classes that represent financial records. The cache policy involves setting the following: Whether the second-level cache is enabled The Hibernate concurrency strategy The cache expiration policies (such as timeout, LRU, and memory-sensitive) The physical format of the cache (memory, indexed files, cluster-replicated) Not all classes benefit from caching, so it s important to be able to disable the second- level cache. To repeat, the cache is usually useful only for read-mostly classes. If you have data that is updated much more often than it s read, don t enable the second-level cache, even if all other conditions for caching are true! The price of maintaining the cache during updates can possibly outweigh the performance benefit of faster reads. Furthermore, the second-level cache can be dangerous in systems that share the database with other writing applications. As explained in earlier sections, you must exercise careful judgment here for each class and collection you want to enable caching for. The Hibernate second-level cache is set up in two steps. First, you have to decide which concurrency strategy to use. After that, you configure cache expiration and physical cache attributes using the cache provider. Built-in concurrency strategies A concurrency strategy is a mediator: It s responsible for storing items of data in the cache and retrieving them from the cache. This is an important role, because it also defines the transaction isolation semantics for that particular item. You ll
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.

Leave a Reply