title: Spring boot - Evicting Cache with dynamic TTL period
body: <p>From my microservice(SERVICE-A) I hit a rest api call to another microservice(SERVICE-B) for login and getting a access token and that API will respond with TTL of that token.
  I need to cache the token till that TTL(seconds) that is responded by SERVICE-B. So my implementation is as below,</p>
  <pre><code>@Cacheable(&quot;USERTOKEN&quot;)
  public String getUserToken()
  {
    //Hits Service-B
    //Gets token and TTL as a response from Service-B
    //Returns Token or Token with TTL
  }
  </code></pre>
  <p>I need to change the above method something as</p>
  <pre><code>@Cacheable(&quot;USERTOKEN&quot;)
  public String getUserToken()
  {
    //Hits Service-B
    //Gets token and TTL as a response from Service-B
    //Sets expiry time for &quot;USERTOKEN&quot; cache   &lt;-- this needs to be added
    //Returns Token or Token with TTL
  }
  </code></pre>
  <p>Even after returning from getUserToken() if it is possible to setExpiryTime for the &quot;USERTOKEN&quot; cache using the TTL returned by getUserToken() it will be fine. We can set Scheduled for eviction but it is going to be a static time period. But here I need it to be set as dynamic value based on the response from Service-B. How can I achieve this.</p>