jsr107 / jsr107spec

JSR107 Cache Specification
Apache License 2.0
413 stars 165 forks source link

add CachingProvider.getCacheManagers() #409

Open evernat opened 4 years ago

evernat commented 4 years ago

There are methods Caching.getCachingProvider(String) and Caching.getCachingProviders(). There are methods CacheManager.getCache(String) and CacheManager.getCacheNames(). There is also a method CachingProvider.getCacheManager(URI, ClassLoader, Properties). But there is currently no method CachingProvider.getCacheManagers().

So there is no way in the JCache api to discover which cacheManagers have been created with URIs. I suggest to add a method getCacheManagers() in CachingProvider to return all known cacheManagers in the cachingProvider whatever URIs were used.

It would be needed to be able to clear all caches of all cacheManagers, after a database synchronisation for example, without having to depend on which URIs were used. This method CachingProvider.getCacheManagers() would be useful for many other things.

eolivelli commented 4 years ago

Is it expected that a CachingProvider holds a reference to every CacheManager?

eolivelli commented 4 years ago

Self answer: yes

I think it is feasible

+1

cruftex commented 4 years ago

So there is no way in the JCache api to discover which cacheManagers have been created with URIs. I suggest to add a method getCacheManagers() in CachingProvider to return all known cacheManagers in the cachingProvider whatever URIs were used.

There is no programmatic API, but you can discover all caches via JMX and clear them.

We cannot add the method in a maintenance release, since this would break compatibility. But for a next major release it seams reasonable to add it.

hjsarrive commented 4 years ago

its will bigger if we add a lot