Вопрос

I am using the oembed feature in L2T to embed tweets in an asp.net app. Twitter recommends that the rsult be cached since it is rate limited. How do I cache Linq to twitter oembed results? Can i use page caching or profile caching or is there a Linq caching method that would be better?

Это было полезно?

Решение

LINQ to Twitter doesn't have any built-in caching support. Generally, there are so many options for this that it wouldn't be wise for me to assume the caching strategy that you would want to design for your own application. That said, I'll identify a few options you might want to consider.

  1. As you mention, output caching is an option and if you add the content to a control, you can effectively cache the page for a certain amount of time. This may or may not work, depending on your freshness requirements for other page content. You can also use this in concert with other types of server caching.

  2. You can use HttpContext Cache, which gives you control over how long an item is cached. This would let you set a timeout on the item and you would need to check to see if the item was in the cache, use it if it's there, or do a Twitter query to get it if not. There's also an option to specify a callback when the cache evicts the item so you can do a query and refresh it.

  3. You could use a 3rd party caching solution, like Enterprise Library Cache. This is nice, has many features and it easy to set up.

  4. If you're on Azure, you can use the Azure caching service, which is nice for scalability.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top