Kentico 8.2 database caching

Peter Wooster asked on April 16, 2020 23:26

I have a module that updates a custom locations table used by the 'find location' page and its child pages. After the update, the pages don't reflect the changed data. I found a TreeNode property TouchCacheDependencies that seems to do what I need, but it is protected. Is there a convenient way to do this?

Correct Answer

Juraj Ondrus answered on August 4, 2020 08:43

So, your custom app is using some API, right? You also mentioned you are publishing the page - does this mean you are using workflows?
If yes, make sure you are also using appropriate API code to work with pages under workflow and publish the changes or edit the right version of the page's history. There is a difference between latest published version and latest edited version. It looks like your code is updating the latest published version - thus it is visible on the live site. However, the Form tab is using the latest edited version of the page's data. Also, please take a look at the DB tables structure to understand how the content is stored.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on April 17, 2020 07:38

Are you updating data directly in the DB? If yes, then Kentico does not know about this so it does not know that the hash tables in the memory have to be refreshed. You either need to restart Kentico application after such updates or use appropriate API methods to update the data through the Kentico API - majority of the API methods for working with the objects do have the logic to refresh the hash tables and "notify" Kentico - "hey Kentico, data changed, load the fresh ones".

0 votesVote for this answer Mark as a Correct answer

Peter Wooster answered on April 17, 2020 14:11

Thanks for the quick reply.

I'm not updating it directly. I'm using the Treenode Update method. The table isn't a standard table. I didn't write this. Updates done through the associated pages form work properly. Is there a way to tell the system not to cache a table, updates to this are not frequent.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on April 17, 2020 14:20

Would it be possible to provide all the details what are you doing, where and what is not updated? Do you mean the data in the admin UI are not updated or on the live site? If on the live site, then in your code you need to ensure the cache is cleared for the live site cache.

0 votesVote for this answer Mark as a Correct answer

Peter Wooster answered on April 17, 2020 15:16

It's both live site and Admin Ui that don't see the updates. The update code is in a module used by the Custom App in the Admin. I've found some errors in the Module definition in the Development/Modules app. Whats in the Development/Modules/CMS/Administration/Custom appears to be correct. I'm going to fix those errors and see if this starts to work properly. As I said, I didn't write this, and I know the author had issues with it.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on April 17, 2020 19:31 (last edited on April 17, 2020 19:31)

when you do caching you have to set cache dependencies correctly. if you keep your data in a custom table, your cache should have dependency on it, i.e. customtableitem.customtable.locationstablename|all if any item has been modified in locationstablename - flush the cache. Dependecies are case sensitive. They all must be low-case.

0 votesVote for this answer Mark as a Correct answer

Peter Wooster answered on July 11, 2020 22:21

I am back to trying to debug this mess. Here's what happens:

  • update the field using the Page Form tab in the Admin Page editor to value 'Set by Form'
  • publish the page
  • go to the Custom app in the Admin and update the field to value 'Set by Custom', this uses the Treenode Update method
  • the value 'Set by Custom' is visible in the Custom App, the front end and the Page and Design tabs in the Admin Page editor
  • the value 'Set by Form' is visible in the Page Form tab.
  • making any change to the fields in the Page Form and publishing makes the value 'Set by Form' visible everywhere.
  • I set the cache times to 10 minutes in the performance app, this did not help.
  • I restarted the machine Kentico was running on, this didn't help
  • where does the Page Form tab get its Field values?
0 votesVote for this answer Mark as a Correct answer

Peter Wooster answered on August 4, 2020 12:26

The custom app is using Treenode.update, but is not using checkin or checkout and the page IS under workflow. I'll try making that change and see if it fixes this problem. Thank you for the example. This system is using 8.2 and that example is from 9, hopefully there is not that much difference.

0 votesVote for this answer Mark as a Correct answer

Peter Wooster answered on August 4, 2020 12:54

I added the CheckIn and CheckOut and it appears to work. It will now need a lot more testing, but thank you again for this very helpful answer.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.