Developer forum

Forum » Development » Clearing the cache

Clearing the cache

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi guys,

We have a multi-server setup using DFS which currently runs on DW 8. We're migrating it to DW 9. The 9.2 version that's available now doesn't have a good solution for clearing remote caches so Nicolai suggested to build my own for the time being. I created a simple module that executes a GET request against all connected servers and calls a custom ashx handler. Inside that handler, I am executing the following code:

      context.Application.Clear();
      Cache.Current.AllKeys.ToList().ForEach(x=> Cache.Current.Remove(x));
      Dynamicweb.Extensibility.ServiceLocator.Current.GetPageService().ClearCache();

Is this a good idea? Looks like I need all three lines to get rid of lots of stuff like ecom data, pages, URLs and so on. Do you see any downsides? Are their other caches that I should clear?

Thanks!

Imar 


Replies

 
Martin Vang
Martin Vang
Reply

Hi Imar,

You also need to clear ParagraphService and AreaService (same as for PageService).

The only clear downside is, that this is going to be ... slow. (at least if this sequence of clear-cache is called often)

We're currently working on NLB, which should fit your current use-case. It is going to be more targeted in what keys get cleared from the different caches in use.

I expect that the NLB will be ready by 9.3.

BR

Martin

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks again Martin; very helpful. I tried the ParagraphService and PageService but they don't have a ClearCache method. Were these recently added? I see them in the source code but not in the DLLs of 9.2.16....

Thanks,

Imar

 
Martin Vang
Martin Vang
Reply

Hi Imar,

Doh! I forgot that I only added those methods for 9.3 a month ago! In 9.3 we'll be using an index for areas and paragraphs the same way we do for PageService, which then needs to be cleared.

The right way of clearing the cache Paragraphs and Areas in 9.2.16, is to clear the Cache the way you do above.

BR

Martin

 

You must be logged in to post in the forum