+ public function __construct (Memcached $memcached) {
+ $this->memcached = $memcached;
+ }
+
+ public static function load (array $config) : self {
+ //Checks extension is okay
+ if (!extension_loaded('memcached')) {
+ if (extension_loaded('memcache')) {
+ throw new CacheException("Can't initialize Memcached cache engine: PHP extension memcached not loaded. This class uses the Memcached extension AND NOT the Memcache extension (this one is loaded).</strong>");
+ } else {
+ throw new CacheException("Can't initialize Memcached cache engine: PHP extension memcached not loaded.");
+ }
+ }
+
+ $memcached = new Memcached;
+ $memcached->addServer(
+ $config["server"] ?? self::DEFAULT_SERVER,
+ $config["port"] ?? self::DEFAULT_PORT,
+ );
+
+ // SASL authentication
+ if (array_key_exists("sasl_username", $config)) {