缓存Linq结果以重用MVC 3

缓存Linq结果以重用MVC 3,linq,asp.net-mvc-3,caching,twitter,Linq,Asp.net Mvc 3,Caching,Twitter,我正在尝试学习如何重用Linqtotwitter结果,以便在应用程序中重用。 一切正常,但如果我不做缓存的话,我会很快达到速率限制。在我的应用程序中,有3个查询点击twitter提要 我试着用一种呼吸模式,但它在我的头上,让我说我没走多远 我的代码中的示例控制器 [HttpGet] public ActionResult PublicShouts() { var twitterCtx = new TwitterContext(Auth);

我正在尝试学习如何重用Linqtotwitter结果,以便在应用程序中重用。 一切正常,但如果我不做缓存的话,我会很快达到速率限制。在我的应用程序中,有3个查询点击twitter提要

我试着用一种呼吸模式,但它在我的头上,让我说我没走多远

我的代码中的示例控制器

    [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);
[HttpGet]
公共行动结果公共呐喊()
{
var twitterCtx=新TwitterContext(Auth);
列出friendstweets=(来自twitterCtx.Status中的tweet
其中tweet.Type==StatusType.User&&
tweet.ScreenName==“战斗呐喊”&&
//tweet.InReplyToScreenName==“战斗呐喊”&&
tweet.IncludeEntities==true&&
tweet.includeReteets==真&&
tweet.includeDistributorDetails==true&&
tweet.CreatedAt
我也看过这篇文章

我怎样才能缓存我的结果以供以后重用,这样我就不会达到twitter的限制


谢谢

OutputCacheAttribute怎么样


查看VaryByCustom,让每个用户都有单独的缓存条目。

缓存控制器操作而不是结果以供重用,我也在使用它。如果您想缓存
列表
请查看
ConcurrentDictionary
我可以使用类似的东西吗?我没有按照您的方向进行。并发字典带我到threadingYes。我提到了并发字典,因为您想从多个线程访问缓存结果。