Apologies if this topic has already been covered before but I couldn't find anything relevant when I searched...
In my application I have a lot of drop-down menus which are populated with options retrieved from the DB. When I want to generate a menu I retrieve all of the values in my (say) videogame categories table, then I loop through these to build the code for the menu; one of the options in the menu will be selected by default depending on whether the record is being created or edited.
My question is this - at the moment, I'm running a query to retrieve the values for every drop-down menu that the script needs to generate and this is a bit redundant because the available options don't change very often. What I'd like to do is find a way to cache the options locally (in a file or in memory) once, then each time I run the add/edit record scripts they look at this file instead of running a query, unless the options in the DB have been updated.
Has anyone tried to do anything like this already? I thought about caching the queries in the DB but the application processes so many different types of queries that this would probably just slow things down, and it seems to make more sense to generate the queries once and save them somewhere so that they'll always be available until the options change i.e. like an included file. This approach assumes that local file access will be much quicker because the disk controller on the server will always have the file in its cache, but I can't quite work out how the script would be able to tell whether the options in the database have changed without querying it?
Thanks in advance,
Mecha Godzilla