What do you mean by invoking the script in this case? Are you invoking it from the command line, or from a web server?
I just did some testing and it looks like PHP Memcached objects with persistence IDs are stored per-PHP-thread.
So if you have 40 PHP threads in your web server, you will have 40 PHP objects that you need to assign servers to before you're guaranteed that the persistence will grab you one that already has the servers assigned. If, on the other hand, you are running from the command line, when the script finishes, the PHP thread will terminate and the Memcached object will be destroyed.
Otherwise, your code looks to me like it will work, but you can just drop the count() call to make it look cleaner, since an empty array evaluates to "false" in an if statement in PHP.
~Ryan