advanced apache cayenne

Click here to load reader

Post on 19-May-2015

1.633 views

Category:

Technology

2 download

Embed Size (px)

TRANSCRIPT

  • 1. Advanced Apache Cayenne(practical demonstration)by Andrus Adamchik, ObjectStyle LLC

2. CMS:Admin appTapestry stack 3. Admin App(demo) 4. Admin App - Takeaway We can reuse Cayenne and service code between the apps When editing objects, ObjectContext is placed in the page scopeand should be reset when we start editing a new object Scope in Tapestry is managed with @Persist annotation 5. Lifecycle Events(demo) 6. Lifecycle Events - Takeway Two ways to receive events - callbacks and listeners Use callbacks on persistent objects for simple things likeinitialization Use listeners for more complex workows, cross-entityworkows Check out DataChannelFilter (will be discussed later) 7. Caching 8. Types of Cache What is cached? Object cache - objects cached by ID Query cache - lists cached by generated cache key 9. Types of Cache Where is it cached? Local cache - attached to an ObjectContext Shared cache - attached to a DataDomain (a common parentof all ObjectContexts) 10. Object Cache(very much like EOF) Stores objects (or DataRows) by ObjectId Prevents unneeded DB trips when navigating object graph Ensures uniquing Can be auto-synchronized across contexts orVMs Memory leak-free (shared - LRU; local - weak refs) 11. Query Cache(nothing like EOF) Stores lists of objects (or lists of DataRows) by query key Prevents unneeded DB trips when running queries Fully managed - time-based or event-based expiration policies Lightweight synchronization via cache groups (inVM, cross-VM) Scales much better 12. Query Cache(demo) 13. Caching and Performance 14. Turn off Cross-ContextSynchronization Good for desktop apps, terrible for webapps unrelated contexts receiving events they dont care about Clustering of object cache doesnt perform well Without clustering, behavior differs for contexts in sameVM vsdifferentVM Object auto-sync will interfere with optimistic locking 15. Turn off Cross-ContextSynchronizationbinder.bindMap(Constants.PROPERTIES_MAP).put(Constants.SERVER_CONTEXTS_SYNC_PROPERTY, "false"); 16. Use Query Cache Design your app with cache groups in mind Implement refresh based on expiration policies Implement refresh based on events and CacheInvalidationFilter Cluster refresh events. Clustering is lightweight, not prone tobreaking on code version changes 17. Consider Optimistic Locking 18. Caching and Performance Dont try to sync individual objects Turn off cross-context synchronization Use query cache. Cluster it. Use optimistic locking 19. Q&AAndrus Adamchikandrus@objectstyle.comtwitter.com/andrus_a

View more