How to implement caching in server application?

Hi,

We are attempting to implement caching in Jira Server. We are mainly using Atlassian Cache 2 as the reference.

A bit about our implementation, we already have a cache implementation that works (the values that get added to the cache are reflected correctly and timely based on the configuration in CacheSettingsBuilder) in Jira Data Center.

We configure the cache settings like so before passing to CacheManager:

CacheSettingsBuilder cacheSettingsBuilder = new CacheSettingsBuilder();
cacheSettingsBuilder
    .remote()
    .replicateViaCopy()
    .cacheSettingsBuilder.expireAfterWrite(3, TimeUnit.MINUTES);

Cache cache = cacheMap.get("some-unique-cache-id");
cache = cacheManager.getCache("some-unique-cache-id", null, cacheSettingsBuilder.build());

But for Jira Server, we are yet to find the configuration that works. By right, cache setting that’s configured like below might be able to work:

CacheSettingsBuilder cacheSettingsBuilder = new CacheSettingsBuilder();
cacheSettingsBuilder
    .expireAfterWrite(3, TimeUnit.MINUTES);

Cache cache = cacheMap.get("some-unique-cache-id");
cache = cacheManager.getCache("some-unique-cache-id", null, cacheSettingsBuilder.build());

We’ve tried:

  • clearing cache from home folder to force the cache to be registered with new cache settings.
  • doing trial and error with other combinations of cache settings.

But none of these work in Jira server. The cache doesn’t reflect the new values that get added to the cache after it reaches the expiry duration.

Appreciate any pointers on this. Thank you!

1 Like

What do you mean “doesn’t work”?

“doesn’t work” - Using the implementation, the cache doesn’t get updated with new entries after it reaches the expiry duration.

(I’ve updated the description to give better clarification on the cache behavior. Let me know if it’s still unclear. Thanks @aron.gombas for pointing that out.)