Chapter 14. Configuring Cache

Chapter 14. Configuring Cache

14.1. About Penrose Cache Types
14.2. Using In-Memory Cache
14.3. Disabling Cache

Penrose Virtual Directory can configure cache settings on data sources and for individual entries. Both caches can be configured to use persistent or in-memory cache or be disabled. The settings for both the source and entry cache affect the Penrose Server performance.

14.1. About Penrose Cache Types

Penrose Studio uses cache at two levels, for the Penrose Server source and another for the Penrose Server entry. The source cache caches the data read from the data sources. The entry cache caches the LDAP entries generated by the mappings. The cache is invalidated when it expires or an update operation is performed against it.

Each source and entry mapping has its own cache which is configured separately, described in Chapter 5, Managing Partitions and Chapter 5, Managing Partitions, respectively, for the cache size and expiration.

The type of cache, however, is configured globally, and Penrose Virtual Directory can configure its cache in two ways:

  • In-memory cache. Storing the cache data in local memroy is fast because it does not require initialization and stores only a partial copy of the data from the source. However, there is a risk since all data are lost when the server is restarted. In-memory cache is recommended for databases that are small or rarely change.

  • No cache (the default). Penrose Server has cache disabled by default, so all operations are run directly against the underlying sources. Disabling cache ensures that the information displayed in Penrose is the same as the data stored in the source. Disabling cach is recommended for using real-time mapping.

There are some performance differences between in-memory cache, persistent cache, and no cache, as shown in Table 14.1, “Performance Measurements for Different Cache Configurations”.

Type of Cache Number of Database Entries Cache Hit Times (in seconds) Cache Miss Times (in seconds)
First Entry Last Entry First Entry Last Entry
No Cache[a] 100 0s 2s
1000 1s 6s
5000 3s 27s
10000 5s 55s
In-Memory Cache 100 0s 2s 0s 2s
1000 0s 6s 1s 6s
5000 1s 25s 3s 27s
10000 8s 60s 8s 60s

[a] If cache is disabled, then there are no entries in the cache. Any search requests, then, appear as a cache miss.

Table 14.1. Performance Measurements for Different Cache Configurations

In-memory cache is configured through a specific module, the CacheModule. This module must be specified in the modules.xml file (either in /opt/vd-server-2.0/conf for the default partition or in /opt/vd-server-2.0/partitions/partition_name/DIR-INF for additional partitions). If the module is not listed in modules.xml, then Penrose Virtual Directory does not use in-memory cache for virtual entries.

  1. Open the modules.xml file.

    cd /opt/vd-server-2.0/conf
    
    vi modules.xml
  2. Configure the cache settings. There are three possible paramters: querySize, which sets the maximum number of unique queries to the cache; resultSize, which sets the maximum number of entries which are returned; and expiration, which sets when the cache expires (in minutes).

    <modules>
    
      <module name="CacheModule">
        <module-class>org.safehaus.penrose.cache.module.CacheModule</module-class>
        <parameter>
          <param-name>querySize</param-name>
          <param-value>250</param-value>
        </parameter>
        <parameter>
          <param-name>resultSize</param-name>
          <param-value>100</param-value>
        </parameter>
        <parameter>
          <param-name>expiration</param-name>
          <param-value>3</param-value>
        </parameter>
      </module>
    
    </modules>
    Parameter Default Value Value Range
    querySize 10 0 (unlimited) to any integer
    resultSize 100 0 (unlimited) to any integer
    expiration 5 0 (never expires) to any integer
  3. As with any module, it is possible to map the CacheModule to a specific subtree in the virtual directory. Add a module mapping entry, specifying the CacheModule, to the modules.xml file. For example:

      <module-mapping>
        <module-name>CacheModule</module-name>
        <base-dn>ou=people,dc=example,dc=com</base-dn>
      </module-mapping>
  4. Restart Penrose Server.

    service vd-server restart

    IMPORTANT

    Always restart Penrose Server after editing the configuration file.

The cache is disabled by setting the enabled= argument for the entry.

  1. Open the modules.xml file.

  2. Add the enabled= argument to the cache's entry, and set its value to false.

    <module name="CacheModule" enabled=false>
  3. Restart Penrose Server.

    service vd-server restart

    IMPORTANT

    Always restart Penrose Server after editing the configuration files.