Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Use the api to flush this cache key: cmsdatasource||en-us|surroundhealth|/topics/my-groups/the-alliance-of-professional-health-advocates/topic-archives/test2|en-us|false|custom.article|||-1|true|0||false View modes: 
User avatar
Certified Developer v6
Certified Developer v6
hoppe - 1/11/2013 11:29:17 AM
   
Use the api to flush this cache key: cmsdatasource||en-us|surroundhealth|/topics/my-groups/the-alliance-of-professional-health-advocates/topic-archives/test2|en-us|false|custom.article|||-1|true|0||false
I found a situation where I want to clear the cache. I went to the site manager > administration > system > debug > cache items and found the cache key that I need to clear. If I remove this key using this interface, it flushes the cache as desired. The key is:

cmsdatasource||en-us|surroundhealth|/topics/my-groups/the-alliance-of-professional-health-advocates/topic-archives/test2|en-us|false|custom.article|||-1|true|0||false


I then tried do the same through the API.

At first I tried using the node ID, since this just is just a single custom document. I ran CacheHelper.TouchKey("nodeid|2312"), which didn't work. The changes aren't apparent when I view the page on the live site. So I tried to flush all documents of that type: CacheHelper.TouchKey("custom.article|all"), which didn't work.

So I tried the full key above, and then I got this error when I view the page:
Unable to cast object of type 'CMS.GlobalHelper.DummyItem' to type 'System.Data.DataSet'.

[InvalidCastException: Unable to cast object of type 'CMS.GlobalHelper.DummyItem' to type 'System.Data.DataSet'.]
CMS.GlobalHelper.CacheHelper.TryGetItem(String key, Boolean caseSensitive, OutputType& output, Boolean logOperation) +418
CMS.GlobalHelper.CacheHelper.TryGetItem(String key, OutputType& value) +74
CMS.GlobalHelper.CachedSection`1.GetData() +110
CMS.GlobalHelper.CachedSection`1..ctor(DataType& result, Int32 cacheMinutes, Boolean condition, String customCacheItemName, Object[] cacheItemNameParts) +103
CMS.Controls.CMSAbstractDataProperties.GetDataSet(String path, String where, Boolean forceReload) +1654
CMS.Controls.CMSAbstractDataProperties.LoadData(Object& DataSource, Boolean forceReload) +244
CMS.Controls.CMSRepeater.ReloadData(Boolean forceReload) +1668
CMS.Controls.CMSRepeater.OnInit(EventArgs e) +178
System.Web.UI.Control.InitRecursive(Control namingContainer) +186
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Control.InitRecursive(Control namingContainer) +421
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2098


How can I clear this item from the cache using the API?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/17/2013 4:14:24 AM
   
RE:Use the api to flush this cache key: cmsdatasource||en-us|surroundhealth|/topics/my-groups/the-alliance-of-professional-health-advocates/topic-archives/test2|en-us|false|custom.article|||-1|true|0||false
Hi,

Have you tried using the dependencies? you can see them in the cache item details. Also, the TouchKey can be called on dummy keys only. It seems that you are calling it on a data key - that's why you are getting the error.

Best regards,
Juraj Ondrus