Skip to content

Instantly share code, notes, and snippets.

@RobGibbens
Created July 5, 2012 14:11
Show Gist options
  • Select an option

  • Save RobGibbens/3053901 to your computer and use it in GitHub Desktop.

Select an option

Save RobGibbens/3053901 to your computer and use it in GitHub Desktop.

Revisions

  1. RobGibbens created this gist Jul 5, 2012.
    14 changes: 14 additions & 0 deletions Cache.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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
    }
    }