Saturday Mini Tip: Memcache flush

Code
Feb 20, 2010
Tags: PHP and Saturday Mini Tip

Memcache can be great to store variables, but beware of Memcache::flush. The function actually requires about 1 second to finish. Below is the best way to handle it:

$oMemcache->flush();

// Wait for memcache to finish flushing
$time = time()+1; //one second future
while(time() < $time) {
//sleep
}

You can find more info here.