I am using the @Cacheable("MyCache") annotation along with the PCC (Pivotal Cloud Cache) provider.
Here is my configuration class
@Configuration
@EnableCachingDefinedRegions
@EnableClusterAware
public class CachingConfig {
}
I see that there is a @Expiration annotation available but it is recommended with @EntityDefinedRegions. Need help with configuring the expiration policy using the @EnableCachingDefinedRegions
Previously, SDG did not support annotation-based expiration configuration (i.e. using @EnableExpiration
) with @EnableCachingDefinedRegions
due to the way the infrastructure beans were created and registered in the Spring container.
However, I decided (see Issue #518) to make some enhancements to the annotation-based configuration model to enable expiration configuration using @EnableExpiration
on Regions defined with @EnableCachingDefinedRegions
.
By way of example, refer to this test case in the EnableExpirationConfigurationIntegrationTests
class of the SDG test suite. The caching/expiration configuration you are looking for is here along with the caching enabled application service class.
Since you are also using SBDG (which is good(!)), then you can simplify the configuration to:
@SpringBootApplication
@EnableClusterAware
@EnableCachingDefinedRegions
@EnableExpiration
public class MySpringBootApacheGeodeApplication {
...
}
By default, the SDG @EnableExpiration
annotation applies to all Regions. However, you can configure the expiration policy per [caching-based] Region using the policies
attribute on the @EnableExpiration
annotation.
Refer to the SDG Reference Documentation for more details.
These changes will be part of the releases coming up this week. Specifically, these changes will be part of SDG 2.5.3
and SDG 2.6.0-M1
. I did not back port these changes to SDG 1.4.x
. The releases go out on Friday, July 16th.