We are using Spring Cache abstration and Infinispan server as a remote cache in front of a slow service.
I have two requirements:
- I would like to create the caches implicitly if they don't exist yet on the remote Infinispan server during access time based on a cache configuration template known by the Infinispan server.
- If the connection to the remote Infinispan server cannot be established I am ok to call the slow service behind it.
Could you suggest how could I implement this?
The built-in @Cacheable annotation does not have support for this.
Should I use a custom annotation with an Aspect? For the second requirement within the Aspect I could handle the connection issue to remote Infinispan server.
Introduced this simple
CustomCacheableannotationand with the following aspect I managed to fulfill both requirements: