Caching
From ETS
To improve application response times caching is used. Perl Cache Modules are used to implement this portion of the application as outlined below.
Showtree Cache
Caches latest downloaded showtree xml document on disk.
- Cache is only invalidated and updated, after cron runs and the new showtree xml document has been downloaded successfully
- Should the showtree api call fail, the document in cache from the last successful download will continue to be used for xql queries
- This works because: A) the showtree document doesn't receive changes at a rapid rate and B) cron is set to run on relatively short intervals.
- Should the showtree api call fail, the document in cache from the last successful download will continue to be used for xql queries
- Showtree Namespace = itunesu
- Showtree Cachekey = stdoc
Having the showtree xml document in cache avoids parsing the entire xml document into memory every time an xql query needs to be satisfied, a time consuming and resource intensive process.
Users Cache
Caches user data to disk via hashes for quick lookups. This avoids repeated xql queries and ldap calls improving response time. Cache is made up of two hashes, each using a user's Penn State Access Id as their keys. The Penn State Access Id is accessible from each page via the REMOTE_USER var. Details for the two hashes are listed now:
- Courselisting Hash
- Key = Penn State Access Id
- Value = a hash having the course handle for the key and the course xml node for the value
- Gathered via showtree xml document
- Courselisting Namespace = itunesu
- Courselisting Cachekey = courselisting
- Entitlements Hash
- Key = Penn State Access Id
- Value = an array of entitlement strings... ("UP:STAT200:004","UP:STAT200:006","UP:STAT200:008")
- Garnered from LDAP
- Entitlements namespace = itunesu
- Entitlements Cachekey = entitlements
Cache Invalidation clears the courselisting and entitlements hashes of all user data key value pairs. Clearing occurs via the showtree.cgi script only after the showtree cron job has run and a new xml document has been downloaded, parsed, and placed into cache.
Cache Additions are made via the user abstraction layer the first time a user visits the dashboard. An xql query and ldap lookup are performed and the results are added to the courselisting and entitlements hashes.
