I have a busness tier with some static methods to fetch common collections. My question is that with web apps I have been doing something that looks like this:
public class StateManager
{
public static StateCollection GetAllStates()
{
StateCollection states = new StateCollection();
if (System.Web.HttpContext.Current.Cache["GetAllStates"] != null)
return System.Web.HttpContext.Current.Cache["GetAllStates"] as StateCollection;
ISortExpression sorter = new SortExpression(SortClauseFactory.Create(StateFieldIndex.State, SortOperator.Ascending));
states.GetMulti(null, 0, sorter);
System.Web.HttpContext.Current.Cache.Insert("GetAllStates", states, null, DateTime.Now.AddHours(12), Cache.NoSlidingExpiration);
return states;
}
}
Is the above code accptable or should I be doing this some other way?