抄的CS里的一段代码。
protected override void OnInit(EventArgs e)
{
List<IndexPost> recentPosts = CSCache.Get("HomePageSearch-" + CurrentCSContext.User.RoleKey) as List<IndexPost>;
if (recentPosts == null)
{
SearchQuery query = new SearchQuery();
query.StartDate = DateTime.Now.AddDays(-10);
query.EndDate = DateTime.Now.AddDays(1);
query.PageSize = 5;
recentPosts = CSSearch.Search(query).Posts;
CSCache.Insert("HomePageSearch-" + CurrentCSContext.User.RoleKey, recentPosts, CSCache.MinuteFactor * 5);
}
RecentPostList.DataSource = recentPosts;
base.OnInit(e);
}
{
List<IndexPost> recentPosts = CSCache.Get("HomePageSearch-" + CurrentCSContext.User.RoleKey) as List<IndexPost>;
if (recentPosts == null)
{
SearchQuery query = new SearchQuery();
query.StartDate = DateTime.Now.AddDays(-10);
query.EndDate = DateTime.Now.AddDays(1);
query.PageSize = 5;
recentPosts = CSSearch.Search(query).Posts;
CSCache.Insert("HomePageSearch-" + CurrentCSContext.User.RoleKey, recentPosts, CSCache.MinuteFactor * 5);
}
RecentPostList.DataSource = recentPosts;
base.OnInit(e);
}