title: How are people handling this caching use case?
body: <p>I have a controller action that is very slow, so I've decided to add caching to it. The way caching is typically used in Rails is something like this:</p>
  
  <pre><code>Rails.cache.fetch("some_key") {
     # expensive operation here, if some_key is not already in the cache store
  }
  </code></pre>
  
  <p>So, if <code>some_key</code> exists in the cache, it's value is being read, and the expensive operation is not executed. The expensive operation would be executed if I delete the key, or, in case it's auto expiring ( based on some database field, or whatever ). Thus, whenever a client would call that controller action, and the cache was just expired, he would have to wait a long time for a response. </p>
  
  <p>To work against this, I've decided to do the invalidation in a separate task, and to replace the cache content ( whenever the key is static ) so that there would be no requests that would take a long time ( I can accept a few seconds of possible stale data responses being sent to the client ). In theory, it seems like a good approach to having good performance. I'd like to knowm are other people using similar techniques in production? Any drawbacks/fatal flaw I'm not seeing to doing something like this?</p>