Developer forum

Forum » Integration » Clear product cache after a scheduled task using SQL Add in

Clear product cache after a scheduled task using SQL Add in

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I know this was surely asked before, but I can't find the answer so I will ask it again.

I have a situation where I need to run a scheduled task based on a SQL Add-in. The task is simply copying the variant product numbers separated with a comma into a custom field on the master product. The purpose is to find the master products when searching for a variant number.

The SQL script does what it's supposed to do. My only issue is with the product cache as the index is not picking up these values right away.
Is there any way I can run the scheduled task and then do something else (preferably without custom code) to clear the cache? I know there are a few suggestions to use some notification subscribers but the customer wants to stay on the "configuration scenario" as much as possible.

Thank you,

Adrian 


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Adrian,
what Dynamicweb version are you using for that: is it DW9 or DW10?
Do you need just clear some service caches for the Products or also rebuilt the product repository index?
BR, Dmitrij

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Dmitrij,

I am using DW 9.18.0. Ideally, I need to rebuild the product repository index afterward.

The logic should have 3 actions:
1. Import products
2. Execute SQL script to add VariantNumbers to master products
3. Rebuild product repository

At this moment, #1 also includes a rebuild of the repository at the end of the import.

Thank you,
Adrian

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Adrian,
it looks like you can make 3 scheduled tasks for that and sort them in the needed order:
1. Create a scheduled task to run the DataIntegration job (the index rebuild can be skipped there)
2. Task to Run the sql script
3. Task to Build repository index with selected product index
BR, Dmitrij

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Dmitrij,

I was thinking about that but it's not clear who's clearing the cache :)

Adrian

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Adrian,
The memory/service cache is cleared in the DataIntegration job, so if you need to clear the cache only after running the sql add-in then you can make an additional task for it with the settings like that (you can also try to select just KillProducts for the Method instead):

And check "Disable cache clearing" in the destination provider settings in the DataIntegration job.
BR, Dmitrij

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Cool!

Thank you!

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Dmitrij,

The method Add-in works just fine.

Now I need to make sure I run the jobs in the right order.

For Product import, I have 2 separate jobs and they are scheduled to run 1 hour between them.
If I add my SQL job after the last import job and check "Run if previous task executed successfully" and sort the Method add-in after the SQL job with the same setting, will they run automatically without having to add an explicit time schedule for them?

Thank you,
Adrian

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

You need to give them all the same start date / time: https://doc.dynamicweb.com/documentation-9/platform/platform-tools/scheduled-tasks#sideNavTitle1-3

>> For Product import, I have 2 separate jobs and they are scheduled to run 1 hour between them.

Is that because you don't know how long it'll take to run them? If so, use the same technique as above and job 2 will run when job1 finishes.

 

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Imar,

Thank you very much. This is very useful.

They are set one hour apart because they are taking around 50 minutes to run.

I will make some tests with the logic you have described and hopefully it works as expected.

Thank you,

Adrian

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> They are set one hour apart because they are taking around 50 minutes to run.

If you schedule them per the above setup (with the same start time) they'll run immediately after each other, whether they take 20, 50 or 70 minutes occasionally.

 
Andrew Rushworth
Reply

Side note:

We use the numbering configuration in our solutions, but the one thing I can't seem to do is prevent subsequent tasks if one fails.Otherwise it works perfectly.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Thank you guys, it's a very useful information.

I will give it a try.


Adrian

 

You must be logged in to post in the forum