Singleton or instance caching?

Although this question primarily relates to EhCache, it does apply to caching structures (and plain old caching) in general.

EhCache allows you to create a singleton CacheManagerto control everything Cachesin your application or create an “instance” CacheManager, which means it looks like: using multiple managers throughout the application.

What are the pros and cons of each? At first a glimpse seems that it would be cleaner just to have a singleton dispatcher.

The only possible reason I can think about why several instance managers are needed is because all the caches living inside CacheManagershould have the same configurations: the same size, usage strategies, capacities, etc. Therefore, if you need several caches, each of which is configured differently, singleton CacheManagerwill not be able to provide different cache configurations to each cache.

Is this the only criterion for defining single-user instance managers? If not, what are some other considerations? Is there any noticeable cost of execution associated with this? Thanks in advance!

+5
source share
1 answer

? , , // ? .

0

All Articles