Re: Performance tuning

Splash Forums Rewrite Users Performance tuning Re: Performance tuning

#22947

Hey Pavel,

Try using the ConfigurationCacheProvider API – you will need to register this in a META-INF/services/org.ocpsoft.rewrite.config.ConfigurationCacheProvider file, but you can implement simple caching using the ServletContext.

This will prevent the rule-set from being re-built on every request. Customize to your needs :)

import javax.servlet.ServletContext;

import org.ocpsoft.rewrite.servlet.config.HttpConfigurationCacheProvider;

public class ServletContextConfigurationCacheProvider extends HttpConfigurationCacheProvider
{
private static final String KEY = ServletContextConfigurationCacheProvider.class.getName() + "_cachedConfig";

@Override
public Configuration getConfiguration(ServletContext context)
{
return (Configuration) context.getAttribute(KEY);
}

@Override
public void setConfiguration(ServletContext context, Configuration configuration)
{
context.setAttribute(KEY, configuration);
}

@Override
public int priority()
{
return 0;
}
}