Skip to content

Instantly share code, notes, and snippets.

@RobGibbens
Created July 5, 2012 14:11
Show Gist options
  • Save RobGibbens/3053901 to your computer and use it in GitHub Desktop.
Save RobGibbens/3053901 to your computer and use it in GitHub Desktop.
Cache
public ActionResult Index()
{
var repo = new Repository();
var dto = repo.GetDtoById(1); // Note, this doesn't know about the cache at all
}
public class Repository()
{
[Cache(Duration = 10)]
public DTO GetDtoById(int id)
{
// if it gets here, go get data from database, note this doesn't know about the cache at all
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment