CHAPTER 13 Optimizing (Linux web host) fetching and caching strategy you d

CHAPTER 13 Optimizing fetching and caching strategy you d like to use for each class and each collection. In the second step, you enable your preferred cache provider in the global Hibernate configuration and customize the provider-specific settings and physical cache regions. For example, if you re using OSCache, you edit oscache.properties, or for EHCache, ehcache.xml in your classpath. Let s enable caching for the CaveatEmptor Category, Item, and Bid classes. 13.4 Caching in practice First we ll consider each entity class and collection and find out what cache concurrency strategy may be appropriate. After we select a cache provider for local and clustered caching, we ll write their configuration file(s). 13.4.1 Selecting a concurrency control strategy The Category has a small number of instances and is updated rarely, and instances are shared between many users. It s a great candidate for use of the second- level cache. Start by adding the mapping element required to tell Hibernate to cache Category instances. The usage=”read-write” attribute tells Hibernate to use a read-write concurrency strategy for the auction.model.Category cache. Hibernate now hits the second-level cache whenever you navigate to a Category or when you load a Category by identifier. If you use annotations, you need a Hibernate extension: @Entity @Table(name = “CATEGORY”) @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE ) public class Category { … } You use read-write instead of nonstrict-read-write because Category is a highly concurrent class, shared between many concurrent transactions. (It s clear that a read committed isolation level is good enough.) A nonstrict-read-write
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply