public static Hashtable GetMongoObjects() { var dict = HttpContext.Current.Cache.Get(ObjKey) as Hashtable; if (dict == null) { var context = new MongoContext(); dict = context.MongoObjects; HttpContext.Current.Cache.Insert(NodeKey, context.TreeNodes, null, DateTime.Now.AddHours(2), Cache.NoSlidingExpiration); HttpContext.Current.Cache.Insert(ObjKey, context.MongoObjects, null, DateTime.Now.AddHours(2), Cache.NoSlidingExpiration); } return dict; }
public static HashSet<MongoTreeNode> GetTreeNodes() { var nodes = HttpContext.Current.Cache.Get(NodeKey) as HashSet<MongoTreeNode>; if (nodes == null) { var context = new MongoContext(); nodes = context.TreeNodes; HttpContext.Current.Cache.Insert(NodeKey, context.TreeNodes, null, DateTime.Now.AddHours(2), Cache.NoSlidingExpiration); HttpContext.Current.Cache.Insert(ObjKey, context.MongoObjects, null, DateTime.Now.AddHours(2), Cache.NoSlidingExpiration); } return nodes; }