Archive for October, 2008

3rd generation MemCached

Monday, October 27th, 2008
$banner->mem->mem->mem->cache_dir = "path/to/cache/dir";

Not confusing at all, no sir!.

OCD code?

Sunday, October 26th, 2008
if (!empty(fetchResult()) and isObject(fetchResult()) and is_a(fetchResult(), "objectType")) {
  $result = fetchResult();
  doSomethingElse();
}
elseif (isObject(fetchResult()) {
  $result = fetchResult();
}

I think the guy who wrote it was slightly OCD. And he definitely forgot that fetchResult() fetches results… from the database.

After optimizing aforementioned code and singleton-ifying the fetchResult(), number of queries made in one pageload went down to 300 from 800. Our code is just awesome.