About Ehcache Configuration
Ehcache supports declarative configuration via an XML configuration file, as well as programmatic configuration via class-constructor APIs. Choosing one approach over the other can be a matter of preference or a requirement, such as when an application requires a certain run-time context to determine appropriate configuration settings.
If your project permits the separation of configuration from run time use, there are advantages to the declarative approach:
Cache configuration can be changed more easily at deployment time.
Configuration can be centrally organized for greater visibility.
Configuration lifecycle can be separated from application-code lifecycle.
Configuration errors are checked at startup rather than causing an unexpected runtime error.
If the configuration file is not provided, a default configuration is always loaded at runtime.
This guide focuses on XML declarative configuration. Programmatic configuration is explored in certain examples and is documented in the
Javadoc.