EAP Labs Ch08 Caching
-
Upload
mainak-basu -
Category
Documents
-
view
217 -
download
0
Transcript of EAP Labs Ch08 Caching
7/29/2019 EAP Labs Ch08 Caching
http://slidepdf.com/reader/full/eap-labs-ch08-caching 1/3
Extending the ATG Platform
Chapter 8: Repository Caching
Catching Up
Completion of Chapter 7 is not required in order to complete the remainingexercises. However, if you were unable to finish and would like to catch up
• Complete the “Catching Up” section from the previous chapter.
• Copy solutions\chapter07\songs.xml to theDynamusicEAP\config\dynamusic folder.
• Copy the JSP file in solutions\chapter07\ to theDynamusicEAP\j2ee-apps\dynamusic-j2ee\dynamusic.war
folder.
Exercise 1: Pre-loading SQL Repository Cache
Exercise Objective
After completing this exercise, you will be able to configure SQL Repository caching and review caching statistics.
Problem Statement
• Pre-load all the items in the Songs Repository when the repository starts up• Enable query caching on items in the Songs Repository • Review caching statistics
Guided Instruction
Pre-load the Songs Repository cache
Pre-loading the cache involves querying the repository defined in a repository
definition file using XML repository operation tags.
1. Before setting up cache pre-loading , view the cache statistics. Open the ATG Administration interface at http://localhost:8080/dyn/admin andselect the Component Browser. Browse to the/dynamusic/SongsRepository component and note the Cache usagestatistics section of the page.
Chapter 8: Exercises 8-1
7/29/2019 EAP Labs Ch08 Caching
http://slidepdf.com/reader/full/eap-labs-ch08-caching 2/3
Extending the ATG Platform
2. Click Reset Cache Statistics so you will see “fresh” statistics the next time you restart ATG.
3. Edit the songs.xml file directly in Eclipse or another text editor. At the endof the file, after all the item-descriptor tags but before the closing gsa-template tag, add a query-items tag for each of the three item types inthe Songs Repository – song, album and artist. The query-items tags will generate a potentially huge amount of output on start-up; to avoid this you can add thequiet="true" attribute to the tags. For this exercise, try adding quiet="true" to the song and album queries, but not to the artistquery so that you can become familiar with the debug output.
4. Test your repository modifications using startSQLRepository. Note thequery output. Resolve any errors before continuing.
5. Restart ATG.
6. Return to the SongsRepository page in the Component Browser, andexamine the Cache usage statistics.
7. In a separate browser window, clear the cached pages in your browser (e.g.,the temporary internet files in IE), then browse through several artists,albums and songs on the Dynamusic site. Reload the cache statistic page andnote the cache hits.
Configure query caching
By default, query caching is disabled, as indicated on the Cache usagestatistics page. You can enable it by setting the query cache size to anumber greater than 0, which is the default value.
8. In each item-descriptor tag in songs.xml, add query-cache-size="100".
9. Test your repository modifications using startSQLRepository.
8-2 Chapter 8: Exercises
7/29/2019 EAP Labs Ch08 Caching
http://slidepdf.com/reader/full/eap-labs-ch08-caching 3/3
Extending the ATG Platform
10. Restart ATG.
11. Browse through several albums, artists and songs on the site, and then reloadthe Cache usage statistics page. Note that query caches are no longerdisabled; instead they appear and show several reused queries.
Note: Queries occur on several pages in the site. Look atsong.jsp for anexample.
Manually invalidate the cache
12. Go to the SongsRepository page in the Component Browser. Find theMethods section, and locate the invalidateCaches method. Click on themethod name to invoke it.
13. Reload the SongsRepository page and note that the caches are now empty.
Chapter 8: Exercises 8-3