When using the Jcache extension and loading Caffeine using the CachingProvider SPI implementation (CaffeineCachingProvider), the cache is easily setup and configured. But the TypeSafe's config does not provide any way to use a dedicated Executor instead of the ForkJoinPool used by default in CaffeineConfiguration.
Which means, to set up a custom Executor, one cannot use the SPI, but needs to manually assemble the pieces and eagerly load the caches as follow :
- load the TypeSafe's Config (
ConfigFactory.load())
- call the
CacheManagerImpl constructor passing the loaded Config
- iterate over all caches defined in the config to call
CacheManagerImpl.createCache with the tuned CaffeineConfiguration built from TypesafeConfigurator.from method.
I may have missed something, but it would be easier if we could specify in the TypeSafe's config :
- an
Executor factory (which could be provided by a Dependency Injection Framework)
- or some kind of customizer/initializer class which could be called to customize the
CaffeineConfiguration before instantiating caches.