【发布时间】:2012-03-21 04:24:37
【问题描述】:
我正在尝试学习如何重用我的 Linqtotwitter 结果以便在我的应用程序中重用。 一切正常,除非如果我不进行某种形式的缓存,我将很快达到速率限制。我的应用程序中有 3 个查询访问了 twitter 提要。
我尝试在http://ardalis.com/introducing-the-cachedrepository-pattern 使用存储库模式,但它超出了我的想象,只能说我没有走远。
我的代码中的示例控制器
[HttpGet]
public ActionResult PublicShouts()
{
var twitterCtx = new TwitterContext(Auth);
List<TweetViewModel> friendstweets = (from tweet in twitterCtx.Status
where tweet.Type == StatusType.User &&
tweet.ScreenName == "BattleShouts" &&
// tweet.InReplyToScreenName == "Battleshouts" &&
tweet.IncludeEntities == true &&
tweet.IncludeRetweets == true &&
tweet.IncludeContributorDetails == true &&
tweet.CreatedAt < DateTime.Now.AddDays(-30).Date
select new TweetViewModel
{
ImageUrl = tweet.User.ProfileImageUrl,
ScreenName = tweet.User.Identifier.ScreenName,
Tweet = tweet.Text
})
.ToList();
return PartialView(friendstweets);
我也看过这个帖子How to cache data in a MVC application
我怎样才能缓存我的结果以供以后重用,这样我就不会达到 twitter 限制?
谢谢
【问题讨论】:
标签: linq asp.net-mvc-3 caching twitter