title: How to keep your distributed cache clean?
body: <p>In a N-Tier architecture, what would be the best patterns to use so that you can keep your cache clean?</p>
  
  <p>I know it's easy to just set an absolute/sliding timeout, but is there a better mechanism available to allow you to mark your cache as dirty after you update the underlying persistence.</p>
  
  <p>The difficulty I"m trying to wrap my head around is that Cache are usually stored as KVP. But a query is usually a fair bit more complex than that. So how can the gateway service tell the cache store that for such and such query, it needs to refetch from persistence.</p>
  
  <p>I also can't afford to hand-code the cache update per query. I'm looking for a more systematic approach.</p>
  
  <p>Is this just a pipe dream, or is there some way to do this elegantly?</p>
  
  <p>Link/Guide/Post appreciated.</p>