Community Add-Ons

Maintainers: retry
Add file to this package
Top » Other

A better tep_reset_cache_block
for osCommerce Online Merchant v2.2

So my friend runs a biz with osC, and he was having major troubles with adding/modifying products. The sql updated, but the browser timed out before finishing the post. Upon investigation we isolated it down to the tep_reset_cache_block() function trying to clear cache files from the cache dir. The cache dir, /tmp/, was filled up with 40,000+ files, so the way tep_reset_cache_block() was iterating through the dir was far too slow and stupid. I have fixed this. He also didn't like that the entire also_purchased cache was removed and not just the cache files pertaining to the product being altered. I fixed this as well.

This new version of tep_reset_cache_block(), uses glob instead of readdir. It's much much faster and also it makes sure there is a properly set pid for the also_purchased cache. This is something of a hack/kludge. I am not familiar enough with the osC codebase to fix the root problem -- merely correct the symptom in the least obtrusive way I could.

This mod should be useful to anyone running a large osC installation and gets a lot of hits and a lot of sessions cached to disk. AFAIK, there are no downsides to this script, but I'm not guaranteeing odd behavior. It certainly shouldn't hose your site.

Legend:  Download   Report

Expand All / Collapse All

Fix on Pid Phocea 25 Jun 2008  

Almso the same as below but removed the logic to only delete also_purchase_products using the pid.

Good idea but if you delete or disable a product, the reset cache block would only delete cache for this product ID and not for all other product that might be linked to it.

Instruction included in the file, only one function to replace.

A better tep_reset_cache_block retry 29 Apr 2007