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

Consider using registerCustomCache from Spring v.5.2.8 #55

Open
stepio opened this issue Jun 14, 2020 · 1 comment
Open

Consider using registerCustomCache from Spring v.5.2.8 #55

stepio opened this issue Jun 14, 2020 · 1 comment

Comments

@stepio
Copy link
Owner

stepio commented Jun 14, 2020

Try reducing amount of custom code by using newly introduced method registerCustomCache.

Links:

@stepio stepio changed the title Use registerCustomCache from Spring v.5.2.8 Consider using registerCustomCache from Spring v.5.2.8 Nov 15, 2020
@vladimirfx
Copy link

Simple customizer:

  CacheManagerCustomizer<CaffeineCacheManager> { cacheManager ->
      for (spec in Binder.get(env).bindOrCreate("caffeine.specs", HashMap::class.java)) {
          cacheManager.registerCustomCache(spec.key.toString(),
              Caffeine.from(spec.value.toString()).build())
      }
  }

Config with proper default (which is not posible with coffee-boots):

spring.cache.type=caffeine
# default (optional)
spring.cache.caffeine.spec=maximumSize=250,expireAfterWrite=15m
# custom configs 0..N
caffeine.specs.places=maximumSize=1000,expireAfterWrite=1h

No deps, no (additional) autoconfiguration magic.

@stepio what do you think - may it be proposed as little PR to Spring Boot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants