0

I am experimenting Cache in Spring Boot. At moment, I am using Caffeine implementation. From what I've read from the documentation, I've configured the caches in YAML as follows:

spring:
  cache:
    cache-names:
      - skills
      - profile-level-type
    caffeine:
      spec: maximumSize=50,expireAfterAccess=60s

Where skills and profile-level-type correspond to different @Services. It is working. However I would like something that more flexible. Apparently, I cannot make a configuration to a specific cache. I was thinking something about this:

spring:
  cache:
    caffeine:
      skills: maximumSize=50,expireAfterAccess=60s
      profile-level-type: maximumSize=5,expireAfterAccess=3600s

Is it possible? If not with Caffeine at least with another cache provider (JCache, EhCache, etc.)?

Rafael Afonso
  • 595
  • 1
  • 10
  • 28
  • There is an alternative provider, [coffee-boots](https://github.com/stepio/coffee-boots), to help with that. This youtuber's [video](https://www.youtube.com/watch?v=ze3qFp5pGeA&t=270s) shows native example where it works out of the box. So maybe it is supported natively in more recent versions (not a spring user). – Ben Manes Apr 06 '22 at 16:47
  • I switched from Caffeine to EhCache to take advantege that I am using JPA / Hibernate cache. Its configuration allows a grained fine config that I was looking for. – Rafael Afonso Apr 08 '22 at 14:52
  • I believe JPA/Hibernate use JCache, so that works in Caffeine if you add the extension. We probably need to add a few samples for Spring & JPA, I just haven't used them since 1.x of each. – Ben Manes Apr 08 '22 at 16:35

0 Answers0