Well, here are some practical examples:
You're building an app using two different libraries, both of which use EhCache for different purposes. To avoid having them interfering with each other, you probably want them using different
CacheManager
s (for example, if lib A doescacheManager.removeCache("foo")
and lib B uses a cache with the same name, you probably won't end up happy).You want caches with different scopes - say, one that lives over the scope of a single request, another with session scope, a third with application scope, etc.
Last, but not least, an important question when one thinks a singleton seems like a good idea - why should the number of instances be limited to exactly one?