Hi all,

I'm currently in the process of building a website with a dynamic navigation menu. This menu is a list of categories a user can click on to view items related to that category. Both the categories and the items are stored in a MySQL db. The items will be changing frequently, however the categories may not change for months at a time (if at all). The categories need to be in the database to link the items to them.

To actually build the navigation menu is going to take 2 db queries per page load, to deal with categories and any sub categories. This is obviously a complete waste of resources and I am looking at caching the generated menu and recreating it periodically to take into account any changes.

I'm thinking about creating my own caching class(es) to take care of this for me, however i'm unsure how to handle access to the page cache. How can i stop someone accessing the cache while it is being recreated? can the php function flock be relied upon to give an exclusive lock on a file? For those of you that have implemented similar solutions how did you resolve these issues?

Thanks for any help you can give

Regards
Mike