ORM and distributed caching

2,649 views
2,549 views

Published on

Slides from meet up in Moscow, 2012 May 17

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,649
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

ORM and distributed caching

  1. 1. ORM and Distributed Caching Alexey Ragozin alexey.ragozin@gmail.com May 2012
  2. 2. ORM cache hierarchy Session Level 1 Query cache Entry cache Level 2 Database
  3. 3. ORM cache hierarchy Session POJO Level 1 Query cache Entry cache Sets of PK Entities Level 2 Database
  4. 4. Second level cacheQuery cache Query -> Result set (list of entry references)Entity cache PK (entry reference) -> Entity dataMakes query cache usefulHelps with “N+1 select” problemActively used for lazy loading of entities
  5. 5. Consistency problemStale data in entity cache = big problemSingle process application Locking, to prevent concurrent updates Write through – modify DB and cache togetherDistributed application1. JTA transaction manager (add cache to Tx)2. Use distributed locks for concurrency control
  6. 6. Solving Query ProblemCaching queries Exact query match may be infrequent Invalidation is messyWhy not execute quires in cache? Execute query in entity cache No invalidation problem Coherence, GemFire, Hazelcast has index support
  7. 7. Queries in Entity CachePro DB is not involved in query processing Fallback to DB for complex quries Still using old good (or bad) JPQLCons ALL entities should be loaded in cache Only simple selects, no join queries are supported  though link traversing works as usual
  8. 8. What is Next? Coherence cache is durable Why update DB synchronously?Write behind for ORMPRO reducing transaction execution time removing DB from critical pathCON Coherence does not honor transaction boundaries DB is out of sync, no way for execution complex JPQL
  9. 9. Few More Interesting Stuff Works with TopLink Grid Real transaction support Durability via distributed disk logHIBERNATE OGM JPQL for NoSQL (data grid included) Lucene (Hibernate Search) support
  10. 10. Thank youhttp://aragozin.blogspot.com Alexey Ragozin alexey.ragozin@gmail.com

×