The power of beer
It's amazing what you can do after a few drinks.
I've just re-written the directory summaries (popular locations, popular categories, popular interests) on BritBlog so that they all use cached data (held in arrays in files) instead of hitting the database with a query each time. I've not done any tests, but it must be loads quicker. The queries used to have two JOINs (i.e. three tables) and WHERE clauses, so they weren't exactly light-weight. The database is on a physically separate server too, so that won't help things either. The cache arrays are updated every four hours via a cron job, so they should never be too out of sync with the real values. All I have to do now is apply a few sorts to them to get the data in the different orders that I need.
I went through and replaced several other database queries in this manner too :-)
I've also added an index of all the interests people have. Again, this is built from a cached snap-shot of the database, so it's pretty swift.
And what did I learn with this exercise? Well, I learned how to use the usort function for sorting multi-dimensional arrays. That's pretty nifty!
Well, this post is boring the tits off me. I'm new to this blogging thing, and when I started one of my planned uses for this blog was to talk about the work I do on BritBlog. So there you have it: work I did on BritBlog.
Got to go to Cambridge tomorrow night (um, actually tonight now). Yet another friend has got engaged (- the world has gone mad!) Still, it should be a good crack. It's always good to meet up with my friends from up there :-)


<< Home