'11211','host2'=>'11211') * @param * string a unique string. prevents conflicts in case multiple apps are using the same memcached server bank */ public function __construct($server_array = array('localhost' => '11211'), $uniquePrefix = "CACHE-") { if (class_exists('Memcache')) { $memcache = new Memcache(); foreach (array_keys($server_array) as $host) { // print "adding server $host " . $server_array[$host]; $memcache->addServer($host, $server_array [$host]); } parent::__construct($memcache, $uniquePrefix, true); } else { $this->LastServerError = 'Memcache client module not installed'; $this->ServerOffline = true; } } /** * @inheritdocs */ public function Get($key, $flags = null) { // prevent hammering the server if it is down if ($this->ServerOffline) { return null; } return parent::Get($key, $flags); } /** * @inheritdocs */ public function Set($key, $val, $flags = null, $timeout = 0) { // prevent hammering the server if it is down if ($this->ServerOffline) { return null; } return parent::Set($key, $val, $flags, $timeout); } /** * @inheritdocs */ public function Delete($key) { // prevent hammering the server if it is down if ($this->ServerOffline) { return null; } return parent::Delete($key); } }