Data Lists and Directories

How to Configure a New Directory Cache

Updated: July 17, 2023

To set up a new cache for your directory, wether for your vocabularies, users or groups:

  1. Contribute a new XML extension that defines your cache:

    • For a Java memory cache:

      <extension target="org.nuxeo.ecm.core.cache.CacheService"
         point="caches">
         <cache name="MYDIRECTORY-ENTRY-CACHE" class="org.nuxeo.ecm.core.cache.InMemoryCacheImpl">
           <ttl>20</ttl><!-- minutes -->
           <option name="maxSize">100</option>
           <option name="concurrencyLevel">500</option>
         </cache>
         <cache name="MYDIRECTORY-ENTRY-CACHE-WITHOUT-REFERENCES" class="org.nuxeo.ecm.core.cache.InMemoryCacheImpl">
           <option name="maxSize">100</option>
           <ttl>20</ttl><!-- minutes -->
           <option name="concurrencyLevel">500</option>
         </cache>
      </extension>
      
    • For a Redis cache:

      <extension target="org.nuxeo.ecm.core.cache.CacheService"
         point="caches">
         <cache name="MYDIRECTORY-ENTRY-CACHE" class="org.nuxeo.ecm.core.redis.contribs.RedisCache">
           <ttl>20</ttl><!-- minutes -->
           <option name="maxSize">100</option>
           <option name="concurrencyLevel">500</option>
         </cache>
         <cache name="MYDIRECTORY-ENTRY-CACHE-WITHOUT-REFERENCES" class="org.nuxeo.ecm.core.redis.contribs.RedisCache">
           <option name="maxSize">100</option>
           <ttl>20</ttl><!-- minutes -->
           <option name="concurrencyLevel">500</option>
         </cache>
      </extension>
      
  2. Adapt the cache parameters if needed:

    • name: The name of the cache
    • ttl: The directory entry life span in the cache
    • maxSize: The maximum number of entries in the cache
  3. For each directory that should use the cache, declare the cache in the directory definition using an XML extension.

    <extension target="org.nuxeo.ecm.directory.sql.SQLDirectoryFactory"
       point="directories">
       <directory name="MYDIRECTORY">
         ...
         <cacheEntryName>MYDIRECTORY-ENTRY-CACHE</cacheEntryName>
         <cacheEntryWithoutReferencesName>MYDIRECTORY-ENTRY-CACHE-WITHOUT-REFERENCES</cacheEntryWithoutReferencesName>
       </directory>
    </extension>
    

    The example above is about a SQL directory. You should adapt the target to the type of directory you're using.