Automatically cache clearing in service now.

ashshri
Kilo Explorer

Hi all,

I am facing a typical requirement which is related to add to cart functionality.

The requirement is first we have to add few items A*, B, C to the cart and just after adding A to the cart we have to hide item 'A', so that user cant able to add it again.

My approach : So we have used User criteria for hiding the item which returns answer = true/false on the basis of row count of cart. if row count greater than zero then it will hide.

Problem faced : After deleting the item A from the cart it will not reappear to user. So it means that cart is not emptied even after deletion of the item. However if I cleared the cache manually by adding cache.do in url then the item will reappear to the user.

So what I require to know that is there any method available to clear cache 'while deleting the last item from the cart'? Or how can we regained that hidden or previous item.

I have found a function gs.cacheFlush()but i am not getting any significance for How to use it.

Please required urgent help!!!

Thanks in Advance.

4 REPLIES 4

vinothkumar
Tera Guru

Hi Ash Shri,



In my opinion, it is normally not a good practice to do the cache clearing during business hours, try for some other alternatives. Still if you want to do it simply call cache.do in any of your server side script.


Slava Savitsky
Giga Sage

gs.cacheFlush() is a server-side method to clear the entire server cache, which you do not want to do in your scenario because it will lead to decreased performance for all users.


Slava Savitsky
Giga Sage

As far as I know, scripted user criteria are not supposed to be cached. It could make sense to reach out to customer support to find out if that's indeed the expected behavior.


ashshri
Kilo Explorer

I still not found any solution !!