'where should we store calculation of list of entities in spring boot?

I have a list of entities, for example, my class "Chain" contains a list of entities "Segment". The segment has some information for example property "distance". I should calculate some value based on distance every time any segment changes. for example when segment added or removed or... I am using Spring Boot and its repositories.

I know that storing result in Chian and updating them is NOT a good idea. But what's the best practice in this case? where should I store results?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source