Improved the cache clear strategy.  This now uses a configuration parameter
that sets the maximum size of the cache and the cache is cleared only
if this size is exceeded.