Skip to content

Conversation

@timyates
Copy link
Contributor

For the past 4 years, we've been using ehcache as the caching layer, but I believe the configuration was incorrect.

We had a block

ehcache:
  caches:
    photo-cache:
      enabled: true
    member-cache:
      enabled: true
    role-permission-cache:
      enabled: true

Which doesn't match any of the cache properties in the docs that I can see...

Then we also had

micronaut:
  caches:
    member-cache:
      expire-after-write: 300
      heap:
        max-entries: 600

Where micronaut.caches.member-cache.heap.max-entries is supposed to be in the ehcache namespace...

And micronaut.caches.member-cache.expire-after-write is a caffeine cache configuration entry, with no analog in ehcache (and it is also expecting a Duration).

In an effort to fix this, I have arbitrarially decided to switch across to use caffeine in place of ehcache, so the consolodated config now looks like:

micronaut:
  caches:
    photo-cache:
      expire-after-write: 1d # 1 day
    member-cache:
      expire-after-write: 300s # 5 minutes
      maximum-size: 600
    role-permission-cache:
      expire-after-write: 1d # 1 day

The ehcache heap.max-entries I have just converted to maximum-size for the caffeine config

I extracted a further class out of the service to actually fetch the image from Google so we can test that the caching is working more easily with Mocks (mocking the service threw away the cache annotations)

@timyates timyates self-assigned this Jun 26, 2024
@timyates timyates merged commit 1bb5945 into develop Jul 1, 2024
@timyates timyates deleted the bugfix-switch-to-caffeine branch July 1, 2024 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants