Make the DbFlat cache TTL configurable from sakai.properties
Description
Environment
Test Plan
is incorporated by
relates to
Activity
Stephen Marquard July 29, 2008 at 11:50 PM
Tested on a trunk build with these sakai.properties:
timeToLive@db.cache.SAKAI_SITE_PROPERTY=11
timeToLive@db.cache.SAKAI_ALIAS_PROPERTY=22
timeToLive@db.cache.SAKAI_REALM_PROPERTY=33
timeToLive@db.cache.SAKAI_SITE_GROUP_PROPERTY=44
timeToLive@db.cache.SAKAI_SITE_PAGE_PROPERTY=55
timeToLive@db.cache.SAKAI_USER_PROPERTY=66
Verified through Admin Workspace / Memory / Status that the TimeToLive values were showing up correctly for the respective caches.
Stephen Marquard July 29, 2008 at 7:27 AM
Tested using this syntax in sakai.properties which works as required:
timeToLive@db.cache.SAKAI_SITE_PROPERTY=99
(for a TTL of 99 seconds in this example).
Reopening to:
1. Back out changes inadvertently introduced related to
2. Remove SAKAI_SITE from list of defined caches in beans (doesn't use DbFlat)
3. Add additional cache beans. cafe trunk build shows these being used:
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_ALIAS_PROPERTY: count:2 hits:2 misses:4 hit%:33
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_REALM_PROPERTY: count:2 hits:12 misses:6 hit%:66
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_SITE_GROUP_PROPERTY: count:0 hits:0 misses:1 hit%:0
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_SITE_PAGE_PROPERTY: count:20 hits:24 misses:117 hit%:17
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_SITE_PROPERTY: count:1 hits:13 misses:12 hit%:52
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_USER_PROPERTY: count:0 hits:1 misses:1 hit%:50
so components.xml should include definitions for the 3 not yet listed, i.e.
SAKAI_ALIAS_PROPERTY, SAKAI_SITE_GROUP_PROPERTY, SAKAI_USER_PROPERTY.

Aaron Zeckoski July 29, 2008 at 4:35 AM
Caches as reconfigured after testing by clicking through a site a couple times (from the memory service tool):
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_REALM_PROPERTY: count:1 hits:8 misses:1 hit%:88
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_SITE: count:0 hits:0 misses:0 hit%:0
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_SITE_PAGE_PROPERTY: count:41 hits:0 misses:41 hit%:0
org.sakaiproject.db.BaseDbFlatStorage.SAKAI_SITE_PROPERTY: count:4 hits:6 misses:4 hit%:60

Aaron Zeckoski July 29, 2008 at 4:33 AM
commit -m "http://jira.sakaiproject.org/jira/browse/SAK-14079
Added in naming and added configurable cache beans as requested by smarquard, tested to make sure the caches are being used
Fixed up the classpath that was broken" /opt/cafe-trunk/db/db-util/.classpath /opt/cafe-trunk/db/db-util/storage/src/java/org/sakaiproject/util/BaseDbFlatStorage.java
Sending /opt/cafe-trunk/db/db-util/.classpath
Sending /opt/cafe-trunk/db/db-util/storage/src/java/org/sakaiproject/util/BaseDbFlatStorage.java
Transmitting file data ...
Committed revision 49502.
Stephen Marquard July 29, 2008 at 1:26 AM
For consistency with other caches, it would also be better to name the DbFlat caches with cache and bean names starting org.sakaiproject.db, as in this example from user-impl/pack/src/webapp/WEB-INF/components.xml
<!-- Memory cache for user lookup. -->
<bean id="org.sakaiproject.user.api.UserDirectoryService.cache"
class="org.springframework.cache.ehcache.EhCacheFactoryBean">
<property name="cacheManager">
<ref bean="org.sakaiproject.memory.api.MemoryService.cacheManager"/>
</property>
<property name="cacheName">
<value>org.sakaiproject.user.api.UserDirectoryService</value>
</property>
<property name="maxElementsInMemory" value="100000" />
<property name="diskPersistent" value="false" />
<property name="eternal" value="false" />
<property name="timeToLive" value="7200" />
<property name="timeToIdle" value="7200" />
</bean>
The default TTL for the DbFlat cache is 5 min. This should be configurable from sakai.properties so that it can be made shorter if required (esp. as there is no cluster-wide cache invalidation).
May need an ehcache.xml config as well - currently using defaults as shown by these log entries:
WARN: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/usr/local/sakai-trunk/shared/lib/ehcache-1.3.0.jar!/ehcache-failsafe.xml (2008-07-25 09:17:18,726 http-8080-Processor24_net.sf.ehcache.config.ConfigurationFactory)
WARN: Creating a new instance of CacheManager using the diskStorePath "/usr/local/sakai-trunk/temp" which is already used by an existing CacheManager.
The source of the configuration was classpath.
The diskStore path for this CacheManager will be set to /usr/local/sakai-trunk/temp/ehcache_auto_created_1216970238729.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance. (2008-07-25 09:17:18,730 http-8080-Processor24_net.sf.ehcache.CacheManager)
Alternately perhaps it should use the MemoryService central ehcache manager.