I need an application level cache in my MVC3 project.
I want to use something like this in the controller:
using System.Web.Caching; protected IMyStuff GetStuff(string stuffkey) { var ret = Cache[stuffkey]; if (ret == null) { ret = LoadStuffFromDB(stuffkey); Cache[stuffkey] = ret; } return (IMyStuff)ret; }
This is not so because Cache ["foo"] does not compile as "System.Web.Caching.Cache - it is a" type ", but is used as a" variable ".
I see that Cache is a class, but there are many examples on the network when it is used as Session ["asdf"] in the controller, as if this property.
What am I doing wrong?
source share