Download - upload.wikimedia.
Transcript
Query Cache • Replicated - Typically refers to a cache that uses JMS, JGroups or some other mechanism to broadcast objects to all servers when read into any of the servers cache. • Distributed15 - Typically refers to a cache that spreads the cached objects across several servers in a cluster, and can look-up an object in another server's cache. TopLink16 / EclipseLink17 : Support an L1 and L2 object cache. LRU, Soft, Full and Weak cache types are supported. A query cache is supported. The object cache is read-write and always transactional. Support for cache coordination through RMI and JMS is provided for clustering. The TopLink18 product includes a Grid component that integrates with Oracle Coherence to provide a distributed cache. 51.5 Query Cache A query cache caches query results instead of objects. Object caches cache the object by its Id, so are generally not very useful for queries that are not by Id. Some object caches support secondary indexes, but even indexed caches are not very useful for queries that can return multiple objects, as you always need to access the database to ensure you have all of the objects. This is where query caches are useful, instead of storing objects by Id, the query results are cached. The cache key is based on the query name and parameters. So if you have a NamedQuery that is commonly executed, you can cache its results, and only need to execute the query the first time. The main issue with query caches, as with caching in general is stale data. Query caches normally interact with an object cache to ensure the objects are at least as up to date as in the object cache. Query caches also typically have invalidation options similar to object caches. TopLink19 / EclipseLink20 : Support query cache enabled through the query hint "eclipselink.query-results-cache". Several configuration options including invalidation are supported. 51.6 Stale Data The main issue with caching anything is the possibility of the cache version getting out of synch with the original. This is referred to as stale or out of synch data. For read-only data, this is not an issue, but for data that changes in-frequently or frequently this can be a major issue. There are many techniques for dealing with stale data and out of synch data. 15 16 17 18 19 20 Chapter Chapter Chapter Chapter Chapter Chapter 51.6.6 on page 270 11 on page 25 10 on page 23 11 on page 25 11 on page 25 10 on page 23 265