/** * Remove instance or whole class from cache or wipe cache out * * If $class and $id are given only instance is removed * If only $class is given all instances of the class are removed * If none of $class and $id are given all instances of all classes are removed * * @param string $class class name * @param mixed $id unique identifier * * @return bool tells if instance/class was registered */ public static function purgeCache($class = null, $id = null) { if ($class) { if (!array_key_exists($class, self::$objectCache)) { return false; } if ($id) { if (!array_key_exists($id, self::$objectCache[$class])) { return false; } unset(self::$objectCache[$class][$id]); } else { self::$objectCache[$class] = array(); } } else { self::$objectCache = array(); } return true; }