Download pulse

Second level cache configuration

The second level cache of Hibernate is always activated for pulse installations. The configurations are split into two files:

  • 2ndLevelCache.xml - this is Hibernate's interal caching configuration as described here.
    It defines which entities and collections shall be cached and whether the cache for these elements shall be "read", "read-write" or "transactional". For single server installations the preset "read-write" caching is recommended.
    <class-cache class="org.torweg.pulse.vfs.VirtualFile" usage="read-write"/>
    <collection-cache collection="org.torweg.pulse.vfs.VirtualFile.children" usage="read-write"/>
    <collection-cache collection="org.torweg.pulse.vfs.VirtualFile.readRoles" usage="read-write"/>
    <collection-cache collection="org.torweg.pulse.vfs.VirtualFile.writeRoles" usage="read-write"/>
    The above sample contains the cache settings for VirtualFile. It caches both the entities and the entities' children, readRoles and writeRoles collections.
  • ehcache.xml - this the configuration for Ehcache - the default second level cache provider of pulse. More details on how to configure the provider can be found on the Ehcache website.
    Within this file the actual behaviour of the cache is controlled, i.e. how many elements shall be cached, the time-to-live, shall the cache overflow to disk, etc.
    <cache name="org.torweg.pulse.vfs.VirtualFile" eternal="true" maxElementsInMemory="5000"
        overflowToDisk="false" timeToIdleSeconds="0" timeToLiveSeconds="0"/>
    <cache name="org.torweg.pulse.vfs.VirtualFile.children" eternal="true"
        maxElementsInMemory="5000" overflowToDisk="false" timeToIdleSeconds="0"
        timeToLiveSeconds="0"/>
    <cache name="org.torweg.pulse.vfs.VirtualFile.readRoles" eternal="true"
        maxElementsInMemory="5000" overflowToDisk="false" timeToIdleSeconds="0"
        timeToLiveSeconds="0"/>
    <cache name="org.torweg.pulse.vfs.VirtualFile.writeRoles" eternal="true"
        maxElementsInMemory="5000" overflowToDisk="false" timeToIdleSeconds="0"
        timeToLiveSeconds="0"/>
    The above is the corresponding part of the Ehcache configuration, which spans an in-memory-cache with 5000 elements each. All cached elements are set to never expire, which is fine since we are using read-write based caching.

The workings of the second level cache should obvious and you can browse through the default settings to get a grip of what is cached in pulse. Obviously, adjusting these settings to match your website can greatly improve performance. The settings chosen as the default a quite generous and should be fine for most sites.