Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document default metadata cache expiration policy #1391

Closed
mmoayyed opened this issue Mar 17, 2023 · 5 comments
Closed

Document default metadata cache expiration policy #1391

mmoayyed opened this issue Mar 17, 2023 · 5 comments
Assignees
Milestone

Comments

@mmoayyed
Copy link

mmoayyed commented Mar 17, 2023

Using version 0.13.0; At the moment, the default cache customizer does the following:

                @Override
		public void customize(javax.cache.CacheManager cacheManager) {
			createMissingCache(cacheManager, "initializr.metadata",
					() -> config().setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.TEN_MINUTES)));
			createMissingCache(cacheManager, "initializr.dependency-metadata", this::config);
			createMissingCache(cacheManager, "initializr.project-resources", this::config);
			createMissingCache(cacheManager, "initializr.templates", this::config);
		}
  • Could the expiration policy, that is Duration.TEN_MINUTES, be configurable via application properties? (I am not sure if it's possible to customize this after the fact)
  • Could this be documented? Was not able to find it here.

I am happy to help and submit a PR if you find this to be reasonable.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 17, 2023
@wilkinsona
Copy link
Contributor

wilkinsona commented Mar 19, 2023

I'm not sure that we want to provide this level of control. The documentation recommends the following approach:

The caches are created with an auto-configured JCacheManagerCustomizer with order 0 and only if they don’t exist already. You can contribute a bean of the same type with a lower @Order to override some of the configuration to suit your specific needs.

Does this not meet your needs?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Mar 19, 2023
@mmoayyed
Copy link
Author

I am not sure that it does. I don't see how to change the expiration policy duration after the cache is built. This turns into an immutable, complete cache and I don't think any customizer can change those settings without some very ugly hacks. I could of course entirely skip this and supply my own cache, or I could entirely skip the feature altogether and do caching entirely on my own but I don't see how that would be immediately better than having a single-lined setting that says "cache duration is X number of minutes".

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Mar 20, 2023
@mmoayyed
Copy link
Author

I went ahead with:

    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    public JCacheManagerCustomizer initializrMetadataCacheManagerCustomizer() {
        return cacheManager -> {
            var cacheDuration = Duration.ONE_DAY;
            var config = new MutableConfiguration<>()
                .setStoreByValue(false)
                .setManagementEnabled(true)
                .setStatisticsEnabled(true)
                .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(cacheDuration));
            log.info("Initialize metadata is cached for 1 day");
            cacheManager.createCache("initializr.metadata", config);
        };
    }

You can certainly close this out, if you still feel like this level of control is unwarranted. (I would nonetheless consider documenting this)

Thank you!

@snicoll
Copy link
Contributor

snicoll commented Mar 23, 2023

I believe this is already documented.

@mmoayyed
Copy link
Author

Certainly, yes; To clarify, I meant that the default duration for the cache should be documented as well. i.e.

The initializr metadata cache by default is configured with an expiration policy that allows entries to remain in the cache for 10 minutes.

@snicoll snicoll changed the title Configurable initializr metadata cache expiration policy Document default metadata cache expiration policy Apr 19, 2023
@snicoll snicoll added type: documentation and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Apr 19, 2023
@snicoll snicoll self-assigned this Apr 19, 2023
@snicoll snicoll added this to the 0.20.0 milestone Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants