PHPBuilder - Another Look: Cached Dynamic Modules Page 3

RSS Twitter

Another Look: Cached Dynamic Modules - Page 3

by: PHP Builder Staff
July 30, 2000

Cache File Locking

I'm performing some complex SQL selects to generate some of these cached modules. Some of them are taking longer than I would like, but priorities demand that I concentrate on tasks other than database performance. I simply added some cron tasks to automate the refreshing of modules in coordination with their tag REFRESH tag. The cron tasks simply request the page from the web server.
However, I was concerned with multiple users hitting the server initiating redundant SQL executions, which would unnecessarily increase the load on the database.
I used a simple locking solution. If the script determines that a cache file needs to be updated, it creates a lock file that indicates the cache file is already being generated. Subsequent requests for that same cache file notice that the lock file exists and wait until that lock file is removed by the initial script and then grabs the cache file when it finishes.
Hopefully, with these enhancements, this solution becomes even more powerful while making it easier to implement for the developer.
You should be able to cut and paste it into your own solution.

« Previous Page
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.




(Maximum characters: 1200). You have characters left.