コード例 #1
0
ファイル: ElggMemcache.php プロジェクト: elgg/elgg
 /**
  * Constructor
  *
  * @param string      $namespace The namespace for this cache to write to
  * @param \Stash\Pool $pool      The cache pool to use. Default is memcache.
  * @param int         $ttl       The TTL in seconds. Default is from $CONFIG->memcache_expires.
  *
  * @throws ConfigurationException
  *
  * @see _elgg_get_memcache() Core developers should use this instead of direct construction.
  */
 public function __construct($namespace = 'default', \Stash\Pool $pool = null, $ttl = null)
 {
     parent::__construct();
     $this->setNamespace($namespace);
     if (!$pool) {
         $pool = _elgg_services()->memcacheStashPool;
         if (!$pool) {
             throw new \ConfigurationException('No memcache servers defined, please populate the $this->CONFIG->memcache_servers variable');
         }
     }
     $this->stash_pool = $pool;
     if ($ttl === null) {
         $ttl = _elgg_services()->config->get('memcache_expires');
     }
     if (isset($ttl)) {
         $this->ttl = $ttl;
     }
     // make sure memcache is reset
     _elgg_services()->events->registerHandler('cache:flush', 'system', array($this, 'clear'));
 }