title: Store data in BEAN (Spring Boot REST)
body: <p>I am creating a REST API with Spring Boot. Most of the data come from a database but some data is fetched from third-party APIs. The problem is some of them have access limitations like max 10 requests per minute or something.
  Now I am looking for a method to cache the data in my spring application and only update it every few seconds. Storing it in the db and updating it every 10 seconds is a little bit too much since the fetched data is about 1000 rows. So I thought I simply store it in my service bean.</p>
  
  <p>This is my approach so far. (Coded in Kotlin)</p>
  
  <pre><code>@Service
  class MyService(){
  
      var myData: CustomDataObject
  
      fun getData() = myData
  
      fun updateData(){
         // call API and store in myData Object
      }
  
  }
  </code></pre>
  
  <p>It works but it seems kinda hacky to me. Not really a clean solution, is it? 
  If someone has a better approach to this I would be very thankful.</p>