Пример #1
0
 function __construct($name, $cfg, $lazy = false)
 {
     parent::__construct($name, $cfg, $lazy);
     // default if not set
     $timeout = $this->cfg["timeout"] > 0 ? $this->cfg["timeout"] : 0;
     $persist = $this->cfg["persist"] ? true : false;
     $this->cache = new Memcache();
     // add to the list
     $servers = any($this->cfg["servers"], $this->cfg["host"]);
     if (!empty($servers)) {
         // If it's a string, assume it's space-separated
         if (is_string($servers)) {
             $servers = explode(" ", $servers);
         }
         foreach ($servers as $server) {
             list($host, $port) = explode(":", $server);
             if (empty($port)) {
                 $port = 11211;
             }
             // default memcache port
             //Profiler::StartTimer("MemcacheCache::addServers()");
             $this->servers[$host] = $params = array("port" => $port, "timeout" => $timeout, "persist" => $persist);
             //Logger::Info("Added memcache server - %s:%s (persist=%d)", $host, $params["port"], $params["persist"]);
             $this->cache->addServer($host, $params["port"], $params["persist"]);
             //Profiler::StopTimer("MemcacheCache::addServers()");
         }
     }
 }
Пример #2
0
 public function __construct($name, $cfg, $lazy = false, $twitterConfig = array())
 {
     parent::__construct($name, $cfg, $lazy);
     $this->authprovider = UserAuthProvider::get("twitter");
     $this->authprovider->build($twitterConfig);
     $this->twitter =& $this->authprovider->twitter;
 }
Пример #3
0
 /**
  * Executes a prepared statement.
  *
  * Returns a boolean value indicating success.
  * Overridden for query counting and logging.
  *
  * @param  array   $input_parameters
  * @return boolean
  */
 public function execute($input_parameters = null)
 {
     $return = $this->statement->execute($input_parameters);
     if ($this->connection->useDebug) {
         $sql = $this->getExecutedQueryString($input_parameters);
         $this->connection->log($sql);
         $this->connection->setLastExecutedQuery($sql);
         $this->connection->incrementQueryCount();
     }
     return $return;
 }
Пример #4
0
 /**
  * Returns a connection to the pool.
  * @param ConnectionWrapper $connection
  */
 public function return_connection($connection)
 {
     if ($connection->op_count >= $this->recycle) {
         $this->stats['recycled'] += 1;
         $connection->close();
         $this->make_conn();
         $connection = $this->get();
     }
     array_push($this->queue, $connection);
 }