Plugins You can find out about all the publicly available Grails plugins.

Multi Tenant EH Cache Support

  • Tags: /
  • Latest: 1.0.1
  • Last Updated: 13 December 2010
  • Grails version: 1.3.0 > *
  • Authors: Scott Ryan
0 vote
compile "org.grails.plugins:multi-tenant-ehcache:1.0.1"




grails install-plugin multi-tenant-ehcache


This plugin supports the single-tenant mode of the multi-tenant pluign. This is the case where each tenant has their own individual database separate from the other tenants. This requires some additional work when managing the 2nd level cache which is needed in most application for performance tuning. This plugin attempts to make the management of the second level cache transparent to the user of the multi-tenant plugin. This process is cache provider specific and this plugin component supports ehcache. There is a plugin component that supports OS Cache as well.

This pluigin supports both versions of the multi-tenant plugin. The original Multi-Tenant plugin and the new refactored Multi-Tenant Core plugin

You do not need this plugin if you are using the multi-tenant mode of the Multi-Tenant plugin. This plugin is only needed for the single-tenant mode.


This plugin provides a plugin cache provider that intercepts the calls to provide a 2nd level cache to Hibernate. It then determines the current tenant and either retrieves a cache or creates a cache for that tenant. The cache provided is a proxy to the real cache. each cache is prepended with the tenant id. The plugin also provides a set of management console screens to allow you to view overall cache performance and detailed performance of each tenants caching scheme down to the individual items in each cache. The support is for the older style of EH Cache which is being replaced and we are looking at how to implement the new style


Configuration of this plugin is very simple. It does require the previous installation of either of the multi tenant core plugins. You then add the following to the datasource.groovy file to replace the current cache provided with the multi tenant one.

cache.provider_class = 'grails.plugin.multitenant.ehcache.cache.MultiTenantEhCacheProvider'

That is all there is to it and now when you start up your application 2nd level caching will support multi-tenant.

Console Configuration

This plugin is built using the dynamic controller plugin so the console controllers are provided as mixins to existing controllers. If you want to add the console support you will need to add the following to your config.groovy file

grails.plugins.dynamicController.mixins = 
    'grails.plugin.multitenant.ehcache.CacheManagementControllerMixin'  :
where com.yourcompany.yourapp.CacheManagementController is a dynamic controller of your naming or an existing controller you wish to plug in to

The initial action you should call on the controller is manage


  • Better Integration with hibernate statistics
    • Currently the statistics module throws and exception when it is called and this provider is present
  • Tenant specific cache sizing and tuning
  • Dynamic cache adjustment on a per tenant basis
  • Trend analysis with history and local storage
  • Graphs and reports on historical cache usage
  • Warning support (email or im)
  • PDF report output

Release Notes

1.0.1 December 13, 2010

  • Fix naming mistake on cache provider from pluign to plugin
  • Fix redirect issue within the controller mixin
1.0.0 - Initial Release

This release matches the 1.0.0 version of the original version.