An open query:
I'm looking for resources and tips concerning the wisdom and best practices of handling data (and possibly preserving) coming out of a DB. Specifically, on my site I'm using mySQL as the definitive source for info that I'm accessing through an object representing a site user. When I ask for info about the user (say $user->get('zipcode')
) I first check if the data is currently defined in the instance. If not, I check the session cache (currently Cache::Filecache) and finally, if it hasn't been found, I query the DB. I store any retrieved info in the instance, then the DESTROY method caches any instance data for later use in this session.
I'm also pre-loading any other relevant data from any called table in anticipation of it being requested (i.e., if I ask for the 'zipcode' I might also ask for the 'street' and 'town', which are on the same record, so get them all on the same DB call.) My records are fairly small, so this shouldn't eat up much memory that wouldn't have been used, and at best avoids several DB calls.
Or so my line of thought goes... but this is all fairly new to me. I can test performance now for an accurate current answer, but I expect the environment I'm running this in to change several times from here to later production use. I thought I'd see if any fellow monks might offer up insight into this area (or share their favorite resource links) so I can anticipate what the best practice might look like. Thanks!