Browsing articles tagged with " caching"

Write-through and Generational Caching Make a Great Team

Sep 28, 2012   //   by Jeff Treuting   //   Blog  //  No Comments

We all know that a great way to speed up any website is to throw some caching at it, right?  When considering caching strategies there are a lot of questions you should be asking.  What type of caching is right for my specific situation?  Do we have to worry about serving up stale data, and if so how do we go about handling that?  Plus another dozen or so questions.  My goal in this post is to show a generic caching strategy that can be implemented in most web applications and just work.

Caching Considerations

“So what exactly are you looking for when it comes to a generic non-website specific caching strategy?” you might probably didn’t ask.  Good question.

  1. Generic implementation
    By that I mean I can just throw it at any new project I’m working on and don’t have to customize it for the type of data I’m dealing with, or any specific cache implementation (i.e. Memcached, in-memory cache, etc.)
  2. Stays out of my way
    I don’t want to have to specifically clear out the cache for my entity whenever it is updated, or manage cache keys to invalidate previous queries.
  3. Don’t serve up stale data
    There are certain situations where stale data is acceptable, but for a generic implementation we want to be conservative and only serve up to date data.

There are 2 types of main data you will be dealing with in your application: single entities (think CRUD) and queries (give me all the posts in a category).  I’ll be dealing with these types differently.  For single entities, I’ll implement write-through caching and for queries I’ll be using generational caching.

Read more >>

Recent Posts