Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Caching on MessageBoard Webpart View modes: 
User avatar
Certified Developer 8
Certified Developer 8
richard - 7/15/2011 5:00:03 PM
   
Caching on MessageBoard Webpart
I am trying to get my head around caching.

Here is the senario:

I have a messageboard web part on a bunch of cms.news documents to allow users to comment.

In another part of the site I have a repeater with a transformation which shows these documents.

I have a custom function which checks the number of comments on each of these documents to shows in the transformation .

What I would like to know is:

1: do I need to write code in my custom function which caches the MessageBoard object for each of the documents (as below)
2: if so, how do I make sure that the cache is cleared when a new comment is added to a message board on a document

Here's what I have so far:

Custom Function to get number of comments on a document:

public static string GetMessageBoardCount(object documentid, object nodeid, string boardname)
{

BoardInfo bi = null;
//check the cache
using (CachedSection<BoardInfo> cs = new CachedSection<BoardInfo>(ref bi, 1, true, null,"BoardCountCache" , documentid + boardname))

{
if (cs.LoadData)//cache item not found
{

bi = BoardInfoProvider.GetBoardInfo(boardname,ValidationHelper.GetInteger(documentid,0));

cs.Data = bi;

CacheDependency cd = null;

cd = CacheHelper.GetCacheDependency(new string[] { "nodeid|" + nodeid.ToString() });

cs.CacheDependency = cd;

}
}

return bi.BoardMessages.ToString();//count of messages

}

Cheers

Richard

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 7/19/2011 2:30:05 AM
   
RE:Caching on MessageBoard Webpart
Hi,

to improve performance you could use caching. For message board web part you could use partial caching. To ensure cache release if the new comment is added you could insert following key into properties of the web part (in Partial caching section):
board.message|all
This will release all message board objects when a new comment is added. If you prefer to release only record related to one document you could use custom data handler and touch your cache keys related to some instance of message board.

For more information please take a look at Deep drive caching.

Best regards,
Ivana Tomanickova