__construct() public method

public __construct ( )
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     $this->CacheType = Gdn_Cache::CACHE_TYPE_FILE;
     $this->RegisterFeature(Gdn_Cache::FEATURE_COMPRESS, array('gzcompress', 'gzuncompress'));
     $this->RegisterFeature(Gdn_Cache::FEATURE_EXPIRY);
     $this->RegisterFeature(Gdn_Cache::FEATURE_TIMEOUT);
 }
Ejemplo n.º 3
0
 public function __construct()
 {
     parent::__construct();
     $this->CacheType = Gdn_Cache::CACHE_TYPE_MEMORY;
     $this->Memcache = new Memcache();
     $this->RegisterFeature(Gdn_Cache::FEATURE_COMPRESS, MEMCACHE_COMPRESSED);
     $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);
 }
Ejemplo n.º 4
0
 /**
  * Setup our Memcached configuration.
  */
 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 ($Persist) {
         $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->registerFeature(Gdn_Cache::FEATURE_SHARD);
     if (C('Garden.Cache.Local', true)) {
         $this->registerFeature(Gdn_Cache::FEATURE_LOCAL);
     }
     $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, Gdn_Cache::FEATURE_SHARD => false, Gdn_Cache::FEATURE_LOCAL => true);
     $DefaultOptions = array(Memcached::OPT_COMPRESSION => true, Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT, Memcached::OPT_LIBKETAMA_COMPATIBLE => true, Memcached::OPT_NO_BLOCK => true, Memcached::OPT_TCP_NODELAY => true, Memcached::OPT_CONNECT_TIMEOUT => 2000, Memcached::OPT_SERVER_FAILURE_LIMIT => 2);
     $Options = $this->option(null, array());
     $Options = array_replace($DefaultOptions, $Options);
     foreach ($Options as $Option => $OptValue) {
         $this->memcache->setOption($Option, $OptValue);
     }
 }
Ejemplo n.º 5
0
 public function __construct()
 {
     parent::__construct();
     $this->CacheType = Gdn_Cache::CACHE_TYPE_NULL;
 }
Ejemplo n.º 6
0
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     parent::__construct();
     $this->RegisterFeature(Gdn_Cache::FEATURE_COMPRESS, array('gzcompress', 'gzuncompress'));
     $this->AddContainer(array(Gdn_Cache::CONTAINER_LOCATION => C('Cache.Filecache.Store')));
 }