Hope you can help me since i'm running out of options...
I have a webshop that runs weekly food plans 1-4 weeks and it has to shuffle menus every week on sunday. Currently I made a service that does that automaticly, it works perfectly and changes the merchEntityCollection -> sortOrder correct with MSSQL in database - BUT it does not refresh my page with new menus untill I either push the webconfig or go into Umbraco and push save / publish.
Is there a way in my service I can refresh Merchello cache so that the correct menu will be displayed on my page without doing anything manually?
I've tried using umbraco.library.RefreshContent(); but that does not work since the nodes inside Merchello are different.
I couldnt find a way to get my Entity CacheKey to use with ClearCacheByKeySearch(), but I managed to get it to work with ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearAllCache() Think it will be okay to use that once a week or is it overkill? I would prefer to use your solution though...but it works now.
Heavy handed indeed :-) My update code is pretty straight forward, I am using ajax to send a request if sort order rotation is being done and if its done it returns result and I then just execute this code:
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearAllCache()
I am using FastTrack and this code is being executed within FastTrack.cshtml
When I use:
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(typeof(IEntityCollection).Name)
Then IEntityCollection tells me:
The type or namespace name 'IEntityCollection' could not be found (are you missing a using directive or an assemly reference?)
IEntityCollection is in the Merchello.Core.Models.Interfaces namespace ... which is actually an error. It should be in the Merchello.Core.Models namespace.
Does it work if you add a using Merchello.Core.Models.Inferfaces statement?
Sorry for replying so late, been busy and didn't get around to trying out your suggestion - but I finally got back to it and it works wonders when adding the Merchello.Core.Models.Interfaces namespace.
Thank you so much for your time and help Rusty Swayne, really appreciated!
Merchello updating Entity Collections SortOrder in database and in need of refreshing cache
Hey guys,
Hope you can help me since i'm running out of options...
I have a webshop that runs weekly food plans 1-4 weeks and it has to shuffle menus every week on sunday. Currently I made a service that does that automaticly, it works perfectly and changes the merchEntityCollection -> sortOrder correct with MSSQL in database - BUT it does not refresh my page with new menus untill I either push the webconfig or go into Umbraco and push save / publish.
Is there a way in my service I can refresh Merchello cache so that the correct menu will be displayed on my page without doing anything manually?
I've tried using umbraco.library.RefreshContent(); but that does not work since the nodes inside Merchello are different.
Best regards, Christian
Bump...Can no one really help me? Do I need to specify my question more?
Hi Christian - I'm out of town, so sorry for the late reply.
My guess is you just need to clear the cache after your operation.
The cache key for Merchello entities is generated here:
https://github.com/rustyswayne/Merchello/blob/merchello-dev/src/Merchello.Core/Cache/CacheKeys.cs#L172
So maybe something as simple as:
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(typeof(IEntityCollection).Name);
?
Hi Rusty,
No problem - I just saw activity in the other posts here. But thank you so much for your suggestion - I will try it out ASAP and report back.
Have a great day!
Best regards, Christian
I couldnt find a way to get my Entity CacheKey to use with ClearCacheByKeySearch(), but I managed to get it to work with ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearAllCache() Think it will be okay to use that once a week or is it overkill? I would prefer to use your solution though...but it works now.
Hmm - must have the prefix slightly incorrect. Can you post your update code? Dumping everything from cache seems pretty heavy handed :-)
Heavy handed indeed :-) My update code is pretty straight forward, I am using ajax to send a request if sort order rotation is being done and if its done it returns result and I then just execute this code:
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearAllCache() I am using FastTrack and this code is being executed within FastTrack.cshtml
When I use: ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(typeof(IEntityCollection).Name)
Then IEntityCollection tells me: The type or namespace name 'IEntityCollection' could not be found (are you missing a using directive or an assemly reference?)
IEntityCollection
is in theMerchello.Core.Models.Interfaces
namespace ... which is actually an error. It should be in theMerchello.Core.Models
namespace.Does it work if you add a
using Merchello.Core.Models.Inferfaces
statement?Issue added to correct the namespacing: http://issues.merchello.com/youtrack/issue/M-1319
Sorry for replying so late, been busy and didn't get around to trying out your suggestion - but I finally got back to it and it works wonders when adding the Merchello.Core.Models.Interfaces namespace.
Thank you so much for your time and help Rusty Swayne, really appreciated!
is working on a reply...