About Cache

Topics: Administration, Customizing Orchard, General
Nov 7, 2011 at 3:57 AM

Hello!

I added my own widget and this widget added to right block(aside second) of site.When any page opening, this widget runing, too. In this widget I'm getting data from other site.When getting data the page opening for a long time And I want to cache this data (ex:for 2 hours).How can I do it?

Any help appreciated!

Developer
Nov 7, 2011 at 11:07 AM

Have a look at this tutorial: http://blogs.realdolmen.com/experts/2011/01/21/writing-an-orchard-widget-latesttwitter/

Or look into this widget: http://orchardproject.net/Gallery/List/Modules/Orchard.Module.WeatherDotCom Probably this is more straightforward if you want caching for a specified amount of time.

Coordinator
Nov 7, 2011 at 4:35 PM

Just as information, in the current work I am doing for the Cache module, this will be done. You will be able to attach a Cache Part to a content type to handle how it's items are cached. And then be able to do donut caching, which would also work with reverse proxy caching (nginx, varnish).

Nov 7, 2011 at 4:58 PM

Sounds great, Sebastien - unfortunately I had to stop using your Cache module for the time being because certain parts of my display are dynamic by requirement. A more flexible solution sounds like I could use it again!

Nov 9, 2011 at 5:40 AM

Thanks to all!

 

Nov 9, 2011 at 5:51 AM
Edited Nov 9, 2011 at 5:54 AM

I solved my problem:

var timeToCache = 30; // will be configurable

 

_cacheManager.Get("CacheKey", ctx => 

 

 

 

{

ctx.Monitor(_clock.When(TimeSpan.FromMinutes(timeToCache))); 

// Operations ...

});