How to clear cache in Opencart from PHP

本秂侑毒 提交于 2021-01-27 06:59:23

问题


I need to clear cache on certain condition from PHP code. How can I do so. I know that there is object Cache exists in opencart engine, but how do delete cache correctly.
Or it is possible to delete just folders ?
Please give advice.


回答1:


In OpenCart there are 3 places that store cache

  1. image cache is located at public_html/image/cache

  2. if you have vQmod public_html/vqmod/vqcache

  3. system (data) cache public_html/system/cache

You can delete files within these folders - do not delete the cache folders - only the content inside.

I hope this helps.




回答2:


What you need to do is to take a look at some models in admin folder and check some add/delete methods, i.e. in admin/model/catalog/product.php the addProduct() method calls:

$this->cache->delete('product');

where 'product' is the key defining which cache to delete. Other keys might be category, language, currency, etc.




回答3:


It works to me- Go to: Step 1. In admin dashboard click in Dashboard and you will get gearing icon in top right side and click on it. You get see Developer Settings. And you get find Cache and Action. So, in Cache click on Off and Click Refresh Icon in Action. Step 2. Admin > Extensions > Modifications > click on the Refresh Icon that you will see in top right side and check again.




回答4:


You can also do it manually or by clearing cache folder files by php script.

If you are using other than 3.X version then the cache folder is in : System > storage > cache

If its a 3.X version then got to storage folder wherever you have moved that then inside that folder there is a cache folder.

Clear cache folder data & reload your store page. This solution worked for me. Thanks for asking this question.



来源:https://stackoverflow.com/questions/28539757/how-to-clear-cache-in-opencart-from-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!