Example #1
0
 /**
  * Constructor
  *
  * @param array   $config
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     if (isset($config['cache_dir'])) {
         $this->_cache_dir = trim($config['cache_dir']);
     } else {
         $this->_cache_dir = Util_Environment::cache_blog_dir($config['section'], $config['blog_id']);
     }
     $this->_exclude = isset($config['exclude']) ? (array) $config['exclude'] : array();
     $this->_flush_timelimit = isset($config['flush_timelimit']) ? (int) $config['flush_timelimit'] : 180;
     $this->_locking = isset($config['locking']) ? (bool) $config['locking'] : false;
     if (isset($config['flush_dir'])) {
         $this->_flush_dir = $config['flush_dir'];
     } else {
         if ($config['blog_id'] <= 0 && !isset($config['cache_dir'])) {
             // clear whole section if we operate on master cache
             // and in a mode when cache_dir not strictly specified
             $this->_flush_dir = Util_Environment::cache_dir($config['section']);
         } else {
             $this->_flush_dir = $this->_cache_dir;
         }
     }
     if (isset($config['use_wp_hash']) && $config['use_wp_hash']) {
         $this->_use_wp_hash = true;
     }
 }
Example #2
0
 /**
  * constructor
  *
  * @param array   $config
  */
 function __construct($config)
 {
     parent::__construct($config);
     $this->_persistent = isset($config['persistent']) && $config['persistent'];
     $this->_servers = (array) $config['servers'];
     $this->_password = $config['password'];
     $this->_dbid = $config['dbid'];
 }
 /**
  * constructor
  *
  * @param array   $config
  */
 function __construct($config)
 {
     parent::__construct($config);
     if (isset($config['persistent']) && $config['persistent']) {
         $this->_config = $config;
         $this->_memcache = new \Memcached($this->_get_key_version_key(''));
         $server_list = $this->_memcache->getServerList();
         if (empty($server_list)) {
             return $this->initialize($config);
         } else {
             return true;
         }
     } else {
         $this->_memcache = new \Memcached();
         return $this->initialize($config);
     }
 }
 /**
  * constructor
  *
  * @param array   $config
  */
 function __construct($config)
 {
     parent::__construct($config);
     $this->_memcache = new \Memcache();
     if (!empty($config['servers'])) {
         $persistent = isset($config['persistent']) ? (bool) $config['persistent'] : false;
         foreach ((array) $config['servers'] as $server) {
             if (substr($server, 0, 5) == 'unix:') {
                 $this->_memcache->addServer(trim($server), 0, $persistent);
             } else {
                 list($ip, $port) = explode(':', $server);
                 $this->_memcache->addServer(trim($ip), (int) trim($port), $persistent);
             }
         }
     } else {
         return false;
     }
     return true;
 }