ElggMemcache::__construct PHP 메소드

__construct() 공개 메소드

Constructor
또한 보기: _elgg_get_memcache() Core developers should use this instead of direct construction.
public __construct ( string $namespace = 'default', Pool $pool = null, integer $ttl = null )
$namespace string The namespace for this cache to write to
$pool Stash\Pool The cache pool to use. Default is memcache.
$ttl integer The TTL in seconds. Default is from $CONFIG->memcache_expires.
    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'));
    }