I have the following, very interesting class …
pubilc class Thing{
public Thing()
{
DoSomethingThatTakesALongTime();
}
public boolean CheckSomething(string criteria)
{
return criteria == "something";
} }
In my ASP.Net MVC application, I need to make a call to CheckSomething very frequently.
As you can see, the constructor takes a long time to load.
What approaches can I use to cache the class? Keep in mind that I want to keep it testable … and I don’t know what that entails!!!!
Cheers,
ETFairfax
You could use the Factory Pattern to create it (Flyweight pattern to share memory)
Create a Factory that returns an instance of the class. The factory would look like this
if instance in cache
if not
For cache you could use HttpContext Cache or Enterprise Library Cache.
EDIT
Interesting discussion below of which pattern this is.
My understanding is as follows: