How to force cache to update when an external app updates the database via API methods?

Keith Donnell asked on November 12, 2015 21:56

I have written a console application that utilizes the Kentico API to perform updates to product inventory from an ERP. Everything is working great, but because Kentico seems to cache everything that is pulled from the DB, I am worried that our inventory updates will not be immediately reflected on the site. I don't want to have to force a full app pool/site reset to apply inventory changes. Is there a way to "dirty" a record, so that Kentico knows to pull fresh data from the DB?

It seems that the only way around this would be to create a middle-man handler/web api within the site that the console app consumes (whether it is a simple "force SKU refresh" [preferred if necessary] or a full API), but I would prefer not having to add another moving part to this process if I can avoid it.

Correct Answer

Keith Donnell answered on November 18, 2015 18:40

It appears neither of these calls within the console app triggers a cache refresh on the server, so I have opted to create the API method I mentioned above and have the console app trigger that.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Timothy Fenton answered on November 13, 2015 12:26

Hello Keith, have you tried using the following:

CacheHelper.TouchKey("com.sku|all");

as this should clear the cache for the com.sku and this:

SKUInfoProvider.Clear(true);

which should clear the hashtables ( most of the 'cached' data for ecommerce is actually stored in the hashtables as opposed to cache. These should help to get you fresh data from the DB, use sparingly, of course, as it will be a crazy performance hit to call this constantly.

0 votesVote for this answer Mark as a Correct answer

Keith Donnell answered on November 17, 2015 20:29

Hi Timothy,

It seems to me that calling either of these would only affect the cache/hashtables in memory wherever the console application is being executed, or are these hashtables you refer to somewhere outside of (the current system's) memory? I'm assuming I will need to create a webapi method that calls this/these methods, and have the console application trigger a call to that api method, correct?

Also, would I need to call both methods in order to affect system-wide refresh of the data I need, or does one method trump the other?

0 votesVote for this answer Mark as a Correct answer

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