micronaut-redis
micronaut-redis copied to clipboard
Fix "BeanInstantiationException" + Add Dynamic cacheEntry creation
"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 a BeanInstantiationException 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.
application.yaml
redis:
enabled: false
host: localhost
port: 6379
caches:
test-cache:
expire-after-write: 24h
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 BypassDynamicCacheManageris 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.
application.yaml
redis:
enabled: false
host: localhost
port: 6379
dynamic:
enabled: true
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.
@sdelamo / @graemerocher any news?