Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there some issue request context where a calculated value of a custom field can be cached?

Irina Svirkina January 17, 2024

We develop a plugin for Jira DC and implemented a calculated custom field. The calculation is heavy.

I observe that Jira triggers a calculation of the calculated custom field several times (4 times) on one issue page load. Why?

public class MyCustomField extends CalculatedCFType<Set<String>, String> {

@Override
public Set<String> getValueFromIssue(CustomField cf, Issue issue) {
// the function is called 4 times on one issue page load.
...
}
}

Is there some atlassian issue context where the calculated value can be cached between the calls to eliminate the extra 3 recalculations? Or how can I tell Jira to trigger the calculation once?

A clarification why the calculation is heavy: unfortunately the custom field is calculated because its value depends on a current jira user (a logged jira user), so we can not simply retrieve it from a lucene index.

1 answer

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 17, 2024

Hi Irina,

I can't explain why fields are called four times on page load without a long essay on how Jira works on the back end and front end, which it has been a long time since I last looked. 

Two of the runs can be explained briefly though

  1. to retrieve the field to work out if there is any display work to do before generating the structure of the whole page
  2. and the other to actually render it

There is no way to cache a field value, and no way to stop Jira running it 2-4 times, it needs to because of what the field is doing.

Irina Svirkina January 18, 2024

Thank you for your reply.

Suggest an answer

Log in or Sign up to answer