Good day to all!

I am writing a web application for spring.

In one of the beans, there is a method that returns the generated string. The resulting line has 2 typical values ​​and changes its value only 2 times a year . It just so happened that I needed to display this very line on EVERY page, but somewhere not even once.

Are there any mechanisms for caching method results?

Thanks in advance for your help.

  • Strictly speaking, the method call itself - if it does not climb into the database and does not do other relatively long things - will not take too much time, so even connecting the standard functionality will most likely take longer than processor seconds will be won due to caching - etki
  • The application also issues requests 2 times a year? - Roman C

1 answer 1

Yes, Spring has a caching mechanism :

@Cacheable("semiannual-string") public String someMethod() { ... }