Brendan Tompkins

Sponsors

The Lounge

Wicked Cool Jobs

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
SharePoint Part Caching (and RTFM)

Okay.  Like most sane people, I try to do most things without reading the manual first.  So, I'm happily developing my SharePoint Portal web parts, and I'm storing data into the PartCache, using the following method.  The method takes 4 values, Storage type, a cache key, the data, and a System.TimeSpan value, like so:

this.PartCacheWrite(Storage.Personal, "test", this.m_strvisibleCameras, new System.TimeSpan(30,0,0,0));

There are no overloads, so you have to pass the TimeSpan.  Well, of course I assumed that the System.TimeSpan value was the time to live for the cache object. Right?  That would make sense, if you've used other cached objects, like Page.Cache. But, I wanted the cache to live forever, so I went looking into the docs and guess what the TimeSpan is for? From the FM:

timeout   A System.TimeSpan that specifies the period during which PartCacheWrite attempts to write a value.

Okay.  Well, I'm SURE they had a great reason for requiring this value and not providing an overload.  But all my code was giving the WebPart 30 days to attempt to write a value.  Next time, I'll try to RTFM.

-Brendan


Posted Wed, Dec 10 2003 6:31 AM by Brendan Tompkins

[Advertisement]

Comments

Brendan Tompkins wrote re: SharePoint Part Caching (and RTFM)
on Wed, Dec 10 2003 3:18 AM
After more research, I've noticed that the above code DOES in fact set the time-to-live for the cache object. MS contradicts the sdk information here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnspts/html/sharepoint_amazonwebparts.asp" From this MS doc:

This is the code used to write to the cache (and to specify a 30-minute timeout period):

PartCacheWrite(Storage.None, cacheKeywordResult,
new KeywordResultCache(keywordReq, productInfo), new TimeSpan(0,30,0));

I've also noticed in my code that this TimeSpan value seems to both set the time-to-live AND the time-to-write. Possibly someone from MS can clairify this for us all.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Devlicio.us