Clear Cache of a product only

Vote:
 

Hi,

EPiServer Comere 8.6.1

I want a function that could Clear the cache (properties, idealy pricing also) of a product without effecting the rest of the site. Any Help

I am happy if it clear the local cache only in load balancing also.

My code will be something like 
ClearProductContentCache(strin product code){
//Clear Cache

******************
CacheHelper.RemoveByPattern("?????");
******************

}

Regards
/K

#116779
Feb 04, 2015 16:48
Vote:
 

Hi,

Unfornately, I don't think it's a good idea to clear cache of a product only. The CatalogCache is used for CatalogEntryDto, but due to Dto nature, an Entry can be cached in multiple CatalogEntryDtos. We did some profiling and see that clean the entire CatalogCache can be faster than using RemoveByPattern to clear a specific cache correctly.

The good news is we are working on this to make the cache more efficient. Stay tuned :)

Regards.

/Q

#116801
Feb 05, 2015 8:27
Vote:
 

Thanks Quan, I need some help here.
Looooooong Story short, background of problem is that


In an Windows Sevice (Integration application) develoers are processing XML
and Save entries using CatalogSystem e.g. this.catalogSystem.SaveCatalogEntry(entryDto);

Those updated changes will not appear in Online Center Commerce section

Work arround written for that was after saving entry by catalog system they have written a service to notify change to website

That does following stuff

CacheHelper.Clear(string.Empty); 

var productLink = referenceConvertor.GetContentLink(productCode, CatalogContentType.CatalogEntry);
var product = (ProductContent)contentLoader.Get<ProductContent>(productLink).CreateWritableClone();
var productSaveAction = product.LoadEntry().IsActive ? SaveAction.Publish: SaveAction.Reject;
contentRepository.Save(product, productSaveAction, AccessLevel.NoAccess);

They used CacheHelper.Clear(string.Empty) method that clears the whole site cache and if we got 1000s item in one feed it is clearing cache every time and in result it effect the live site very badly. In result as long as integration application is running site remains near about unresponsive.

Without  clearing cache it doesnot save/publish latest changes.

waiting for your advice/help on this. 


Regards
/K

#116816
Feb 05, 2015 12:38
Vote:
 

When you call this: 

contentRepository.Save(product, productSaveAction, AccessLevel.NoAccess);

CatalogCache should be cleared already. CacheHelper.Clear(string.Empty) will clear entire HttpContext.Current.Cache or HttpRuntime.Cache, so yes, it's very ineffficient. 

What is your "Online Center Commerce section"? You mean Catalog UI?

I think the better solution is to make sure your Windows Service to have proper event handling. I think your service is missing event configuration so it can't raise event to let the website knows there's change. If it's configured correctly then we do the synchronization just fine :)

Configurations can be found in <system.serviceModel> section of web.config.

Regards.

/Q

#116819
Feb 05, 2015 13:06
Vote:
 

Well, Correct me If I am wrong

If I Set up below settings in my Windows Service

http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/75/Event-management/WCF-event-management/

then I wouln't need to publish as we are doing at this stage.

Correct?

Regards
/K

#116822
Feb 05, 2015 13:13
Vote:
 

Yes, if the event system is working then after you saving an entry, it should appear in any where, both in Commerce Manager and in Catalog UI without additional steps.

Regards.

/Q

#116824
Feb 05, 2015 13:16
Vote:
 

I will give it a try, Thanks for your time.

#116826
Feb 05, 2015 13:18
Vote:
 

I am using same settings in

Front Website
Commerce Manager Site
Windows Client

<system.serviceModel>
<extensions>
<bindingElementExtensions>
<add name="udpTransportCustom" type="Microsoft.ServiceModel.Samples.UdpTransportElement, EPiServer.Events" />
</bindingElementExtensions>
</extensions>
<services>
<service name="EPiServer.Events.Remote.EventReplication" behaviorConfiguration="DebugServiceBehaviour">
<!--<endpoint name="RemoteEventServiceEndPoint" contract="EPiServer.Events.ServiceModel.IEventReplication" bindingConfiguration="RemoteEventsBinding" address="net.tcp://localhost:13000/RemoteEventService" binding="netTcpBinding"/>-->
<endpoint name="RemoteEventServiceEndPoint" contract="EPiServer.Events.ServiceModel.IEventReplication" binding="customBinding" bindingConfiguration="RemoteEventsBinding" address="soap.udp://239.255.255.19:5000/RemoteEventService" />
</service>
</services>
<client>
<!-- Uncomment this endpoint and the "RemoteEventServiceEndPoint" to enable remote events -->
<endpoint name="RemoteEventServiceClientEndPoint" address="soap.udp://239.255.255.19:5000/RemoteEventService" binding="customBinding" bindingConfiguration="RemoteEventsBinding" contract="EPiServer.Events.ServiceModel.IEventReplication" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="DebugServiceBehaviour">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="EPiServer.Business.Commerce.EventServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="CommerceSiteBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EventServiceEndpointBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="RemoteEventsBinding">
<binaryMessageEncoding />
<udpTransportCustom multicast="True" />
</binding>
</customBinding>
</bindings>
</system.serviceModel>

With changes in windows client, I can see the updates in Commerce Manager through catlog Management
Press F5, changes are not visible in Online center Catalog UI.
If I Save that product from Commerce Manager, Changes are visible in Catalog UI 

Didn't worked. Any idea?

#116846
Feb 05, 2015 17:09
Vote:
 

It looks like your service is also missing the configuration for Framework, it should have something like this:

<episerver.framework>
<scanAssembly forceBinFolderScan="true" />
<appData basePath="appData" />
</episerver.framework>

This allows Framework to scan the assembly and register types related to event system.

Regards.

/Q

#116853
Feb 06, 2015 2:49
Vote:
 

Didn't work. can I forward you app.config on your email (i have your email address). 

Regards
/K

#116855
Feb 06, 2015 9:28
Vote:
 

Sure :)

I will try to take a look when I have time. But if I can't resolve it in a reasonable timeframe you will need to contact our developer support service.

Regards.

/Q

#116869
Feb 06, 2015 13:26
Vote:
 

for updates...
I couldn't  manage catalog events yet but mean while i found this interesting thing

DataFactoryCache.RemovePage(productLink);
DataFactoryCache.RemoveListing(productLink);

It is clearing cache for a particular product/variant, I am wondering in there any catalyst you are aware of if i use this function.

Regards
Khurram

#117385
Feb 19, 2015 16:55
Vote:
 

If you enable debug output for EPiServer.Events in the site, can you see that it is actually receiving the cache invalidation event? Also, I am not really familiar with UDP-configured remote events, but as for TCP the config shouldn't be the same in all sites. Depending on who's broadcasting and who's listening the configs differ.

#117391
Feb 19, 2015 18:42
Vote:
 

(UDP)Receiving is OK but Broadcasting from Integration application is an issue. 
Regards
/K

#117875
Feb 23, 2015 14:05
Vote:
 

With commerce 8.9 you have new possibilities to work with cache dependencies for this: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Commerce/8/Caching/Caching/

#118565
Mar 10, 2015 10:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.