Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Can't expire a custom cache entry when a custom table entry is modified View modes: 
User avatar
Member
Member
joeh42 - 5/22/2012 1:13:21 PM
   
Can't expire a custom cache entry when a custom table entry is modified
I read through the caching deep dive, but I still have a question.

I have a custom table whose code name is customtable.FeaturedContent2 (namespace.customTable). I have a custom web part that pulls data from the custom table:
        DataSet dataSet = null;
using (var cs = new CachedSection<DataSet>(ref dataSet, 60, true, null, "featured-getCustomTableData|", isActive))
{
if (cs.LoadData)
{
var dataInfoClass = getDataInfoClass();
var ctiProvider = getItemProvider();

string where = (isActive) ? "[IsActive] = 1" : "[IsActive] = 0";

dataSet = ctiProvider.GetItems(dataInfoClass.ClassName, where, "[ContentClassName]");
cs.CacheDependency = CacheHelper.GetCacheDependency("featuredcontent2|all");
cs.Data = dataSet;
}
}
return dataSet;


When I step through the code, I see that the code only enters the if statement the first time, so the caching is working.

However, if I go to CMS Desk > Tools > Custom tables > Featured Content2 > Edit custom table item, make a change, and hit save, I thought that Kentico would then expire this cache item. The code, in theory, would then enter the if statement and load the freshest data.

But stepping through the code, the API loads the item from the cache, and does not enter the if statement.

I also tried changing the getcachdependency line:
CacheHelper.GetCacheDependency("customtable.featuredcontent2|all");


But this has the same result as the previous.

Is my cache key set correctly?

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/23/2012 2:49:11 AM
   
RE:Can't expire a custom cache entry when a custom table entry is modified
Hello,


the format of the cache key in the GetCacheDependency method is correct but please double check the class name - the best way is looking to the CMS_Class table in your database and finding the exact ClassName of your custom table.

Please let me know if it helps.


Best regards,
Helena Grulichova

User avatar
Member
Member
joeh42 - 5/23/2012 10:48:18 AM
   
RE:Can't expire a custom cache entry when a custom table entry is modified
Hi Helena,

I ran the query below to get my classname:
SELECT LOWER([ClassName])
FROM [CMS_Class]
WHERE
ClassName LIKE '%featured%'
OR ClassDisplayName like '%featured%'


It returns 'customtable.featuredcontent2', which I was using above (customtable.featuredcontent2|all), but the cache is still not getting expired when using the cmsdesk edit custom table item module. I'm using the debugger to step through my code to see if cs.loaddata is true.

Do you recommend that I contact support?

Thank you for showing me where the class names are stored. That will be very useful.

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 5/24/2012 6:51:34 AM
   
RE:Can't expire a custom cache entry when a custom table entry is modified
Hello,


I have tested the issue and consulted with our developers. It should be:

CacheHelper.GetCacheDependency("customtableitem.customtable.featuredcontent2|all");

if you want to flush the cache when you manage the custom table items. I am sorry for confusing. I hope it will help.


Best regards,
Helena Grulichova

User avatar
Member
Member
joeh42 - 6/5/2012 10:53:31 AM
   
RE:Can't expire a custom cache entry when a custom table entry is modified
It worked. Thanks!

Joe Hoppe
Kentico Certified Developer

User avatar
Member
Member
pnmcosta - 11/12/2013 4:56:54 PM
   
RE:Can't expire a custom cache entry when a custom table entry is modified
Just doesn't work for me when changing the order of the items, does it use another cache dependency key?

Thanks,
P.

User avatar
Kentico Support
Kentico Support
kentico_romank - 11/14/2013 4:19:24 AM
   
RE:Can't expire a custom cache entry when a custom table entry is modified
Hi,

Could you please clarify what exactly do you mean by "changing the order of the items"? Do you mean changing the order of fields of custom table or changing the order of data?

Thank you for information.

Best Regards,
Roman Konicek

User avatar
Member
Member
pnmcosta - 11/14/2013 5:41:06 AM
   
RE:Can't expire a custom cache entry when a custom table entry is modified
Hi Roman,

The order of data via the CMS desk (up/down arrows).

Cheers,
P.

User avatar
Kentico Support
Kentico Support
kentico_romank - 12/2/2013 6:37:00 AM
   
RE:Can't expire a custom cache entry when a custom table entry is modified
Hi,

I have consulted this issue with our developers and regrettably, this seems to be a bug in the current version. I'm very sorry for this inconvenience. We will try fix it in the next version or in the next hotfix package for this particular Kentico CMS version.

Best Regards,
Roman Konicek