/**
* Reads in known/config servers and adds them to the instance.
*
* This method is called when the cache object is invoked by the framework
* automatically, and needs to configure itself from the values in the global
* config file.
*/
public function autorun()
{
$Servers = Gdn_Cache::activeStore('memcached');
if (!is_array($Servers)) {
$Servers = explode(',', $Servers);
}
// No servers, cache temporarily offline
if (!sizeof($Servers)) {
SaveToConfig('Cache.Enabled', false, false);
return false;
}
// Persistent, and already have servers. Short circuit adding.
if ($this->Config(Gdn_Cache::CONTAINER_PERSISTENT) && count($this->servers())) {
return true;
}
$Keys = array(Gdn_Cache::CONTAINER_LOCATION, Gdn_Cache::CONTAINER_PERSISTENT, Gdn_Cache::CONTAINER_WEIGHT, Gdn_Cache::CONTAINER_TIMEOUT, Gdn_Cache::CONTAINER_ONLINE, Gdn_Cache::CONTAINER_CALLBACK);
foreach ($Servers as $CacheServer) {
$CacheServer = explode(' ', $CacheServer);
$CacheServer = array_pad($CacheServer, count($Keys), null);
$CacheServer = array_combine($Keys, $CacheServer);
foreach ($Keys as $KeyName) {
$Value = val($KeyName, $CacheServer, null);
if (is_null($Value)) {
unset($CacheServer[$KeyName]);
}
}
$this->addContainer($CacheServer);
}
}