What would be a realworld example of an application having multiple Cache Manager in Ehcache?

StackOverflow https://stackoverflow.com/questions/21405857

  •  03-10-2022
  •  | 
  •  

문제

According to Ehcache, an application can have multiple CacheManagers. Since multiple cache's can be maintained in a single CacheManager, what benefit are we getting by having multiple CacheManagers? Is distributec cache has any relation with multiple CacheManagers? I tried googling it and found none. Please correct me if my understanding is wrong.

도움이 되었습니까?

해결책

Well, here are some practical examples:

  1. 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 CacheManagers (for example, if lib A does cacheManager.removeCache("foo") and lib B uses a cache with the same name, you probably won't end up happy).

  2. 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.

  3. 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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top