[There already is a method like that …](https://github.com/owncloud/core/blob/master/lib/memcache/factory.php#L38)