Gdn_Cache::__construct PHP Method

__construct() public method

public __construct ( )
    public function __construct()
    {
        $this->containers = array();
        $this->features = array();
    }

Usage Example

コード例 #1
0
 public function __construct()
 {
     parent::__construct();
     $this->CacheType = Gdn_Cache::CACHE_TYPE_MEMORY;
     // Allow persistent connections
     /**
      * EXTREMELY IMPORTANT NOTE!!
      * There is a bug in Libmemcached which causes persistent connections not 
      * to be recycled, thereby initiating a spiral of memory loss. DO NOT USE
      * THIS UNLESS YOU ARE QUITE CERTAIN THIS IS SOLVED!
      */
     $Persist = $this->Config(Gdn_Cache::CONTAINER_PERSISTENT);
     if ($this->Config(Gdn_Cache::CONTAINER_PERSISTENT)) {
         $PoolSize = $this->Config(Gdn_Cache::CONTAINER_POOLSIZE, 10);
         $PoolKeyFormat = $this->Config(Gdn_Cache::CONTAINER_POOLKEY, "cachekey-%d");
         $PoolIndex = mt_rand(1, $PoolSize);
         $PoolKey = sprintf($PoolKeyFormat, $PoolIndex);
         $this->Memcache = new Memcached($PoolKey);
     } else {
         $this->Memcache = new Memcached();
     }
     $this->RegisterFeature(Gdn_Cache::FEATURE_COMPRESS, Memcached::OPT_COMPRESSION);
     $this->RegisterFeature(Gdn_Cache::FEATURE_EXPIRY);
     $this->RegisterFeature(Gdn_Cache::FEATURE_TIMEOUT);
     $this->RegisterFeature(Gdn_Cache::FEATURE_NOPREFIX);
     $this->RegisterFeature(Gdn_Cache::FEATURE_FORCEPREFIX);
     $this->StoreDefaults = array(Gdn_Cache::FEATURE_COMPRESS => FALSE, Gdn_Cache::FEATURE_TIMEOUT => FALSE, Gdn_Cache::FEATURE_EXPIRY => FALSE, Gdn_Cache::FEATURE_NOPREFIX => FALSE, Gdn_Cache::FEATURE_FORCEPREFIX => NULL);
     foreach ($this->Option(NULL, array()) as $Option => $OptValue) {
         $this->Memcache->setOption($Option, $OptValue);
     }
 }
All Usage Examples Of Gdn_Cache::__construct