Java Persistence/Caching

From Wikibooks, the open-content textbooks collection

< Java Persistence
Jump to: navigation, search

Contents

[edit] Caching

Caching is the most important performance optimization technique. There are many things that can be cached in persistence, objects, data, database connections, database statements, query results, meta-data, relationships, to name a few. Caching in object persistence normally refers to the caching of objects or their data. Caching also influences object identity, that is that if you read an object, then read the same object again you should get the identical object back (same reference).

JPA does not define a server object cache, JPA providers can support a server object cache or not, however most do. Caching in JPA is required with-in a transaction or within an extended persistence context to preserve object identity, but JPA does not require that caching be supported across transactions or persistence contexts.

There are two types of object caching. You can cache the objects themselves including all of their structure and relationships, or you can cache their database row data. Both provide a benefit, however just caching the row data is missing a huge part of the caching benefit as the retrieval of each relationship typically involves a database query, and the bulk of the cost of reading an object is spent in retrieving its relationships.

[edit] Object Cache

[edit] Data Cache

[edit] Caching Relationships

[edit] Cache Types

[edit] Object Identity

[edit] Query Cache

[edit] Stale Data

[edit] Refreshing

[edit] Cache Invalidation

[edit] Caching in a Cluster

[edit] Cache Transaction Isolation

Personal tools
Create a book
  • Add wiki page
  • Collections help