Fix "BeanInstantiationException" + Add Dynamic cacheEntry creation #629
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
"BeanInstantiationException" on redis.enabled=false
In some cases it necessary to deactivate the caching mechanism, for example in a local development setting. Therefore I want to disable Redis and bypass the caching mechanism.
Currently there is a flag to disable Redis
redis.enable=false
, but this leads to aBeanInstantiationException
on the first load of the CacheManager.Caught unexpected error 'BeanInstantiationException' on API level with message: Error instantiating bean of type [io.micronaut.cache.DefaultCacheManager]
Example configuration.
This PR should fix this Error by considering the "redis.enable"-property in the
RedisCache
-Class. It should only be instantiated, when Redis is enabled.Additionally
BypassDynamicCacheManager
is added, to bypass the cache mechanism, by using the DynamicCacheManger functionality of the Micronaut-Cache implementation.Dynamic CacheEntry creation without having an explicit configuration by using DefaultCacheConfiguration.
As an additional feature a DynamicCacheManger is added. It will use the DefaultCacheConfiguration to create dynamically CacheEntries without having an explicit configuration in the application.yaml.
This should decouple more the Configuration with the Annotations in the code.
It also should behaves like the Hazelcast Cache implementation, that also creates dynamic CacheEntries if a configuration is missing.