Attribute Caching
CachingPersonAttributeDaoImpl
Delegates queries to the configured child IPersonAttributeDao and caches the results based using a key generated from the query using attributes specified in the configuration.
Setting up a CachingPersonAttributeDaoImpl in Spring to would look like the following:
<bean id="cachingPersonAttributeDao" class="org.jasig.services.persondir.support.CachingPersonAttributeDaoImpl"> <property name="cachedPersonAttributesDao" ref="mergingPersonAttributeDao" /> <property name="userInfoCache" ref="userInfoCacheMap" /> <property name="cacheNullResults" value="true" /> </bean>
This configuration will cache results of method calls on mergingPersonAttributeDao in userInfoCacheMap. The cache keys are generated using AttributeBasedCacheKeyGenerator by default and in the default configuration the username attribute is used for the key. Also null results will be cached, meaning if a query against mergingPersonAttributeDao is a miss or cannot be run (null returned) an marker will be cached to avoid repeated null lookups.
Configuration
LdapPersonAttributeDao has an anonymous contstructor.
Property |
Type |
Default Value |
 |
---|---|---|---|
defaultAttribute |
String |
username |
The attribute name to use for calls to IPersonAttributes getPerson(String). A query Map is generated for these calls using the defaultAttribute and the value passed in. |
cachedPersonAttributesDao |
IPersonAttributeDao |
null |
The IPersonAttributeDao to cache results from. |
cacheKeyGenerator |
CacheKeyGenerator |
new AttributeBasedCacheKeyGenerator() |
An implementation of the Spring-Modules Caching CacheKeyGenerator API to use to generate cache keys. The use of this interface also allows AOP based caching using the CacheKeyGenerator implementation directly. |
userInfoCache |
Map<Serializable, Set<IPersonAttributes>> |
null |
The cache to store results in. Only the get, set and remove methods are used on the Map interface so most commonly a wrapper around a real caching interface is used. |
cacheNullResults |
boolean |
false |
If null results (meaning a child DAO could not complete the query) are returned should they be cached as well to avoid multiple 'failure' lookups. |
AttributeBasedCacheKeyGenerator
Implements the Spring-Modules Cache CacheKeyGenerator API and is used by the CachingPersonAttributeDaoImpl to generate cache keys for queries.
Configuration
Property |
Type |
Default Value |
 |
---|---|---|---|
cacheKeyAttributes |
Set<String> |
null |
Query Map attributes to be used when building the cache key. |
defaultAttributeName |
String |
username |
Attribute name to use for calls to IPersonAttributeDao.getPerson(String) |