(I use the word var in the following because I'm not sure what it is I think it's a global variable for the class)
I want to cache values that are gotten from a table in a database, to save repeated queries. What I've done is create a singleton class which has a function to check a var within the class if a key exist, if it does then just return the value from the var, if it doesn't then query the database and load it into the var and return it.
Or would a better way of doing it be using a global variable (does a global variable have the same value no matter from which file accesses it?) and not using a class at all.
Or don't bother caching and just query the database every time the value is needed.
Should I post the source of what I've come up with?