當前位置: 首頁>>代碼示例>>PHP>>正文


PHP cache::__construct方法代碼示例

本文整理匯總了PHP中cache::__construct方法的典型用法代碼示例。如果您正苦於以下問題:PHP cache::__construct方法的具體用法?PHP cache::__construct怎麽用?PHP cache::__construct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cache的用法示例。


在下文中一共展示了cache::__construct方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Override the cache::construct method.
  *
  * This function gets overriden so that we can process any invalidation events if need be.
  * If the definition doesn't have any invalidation events then this occurs exactly as it would for the cache class.
  * Otherwise we look at the last invalidation time and then check the invalidation data for events that have occured
  * between then now.
  *
  * You should not call this method from your code, instead you should use the cache::make methods.
  *
  * @param cache_definition $definition
  * @param cache_store $store
  * @param cache_loader|cache_data_source $loader
  */
 public function __construct(cache_definition $definition, cache_store $store, $loader = null)
 {
     // First up copy the loadeduserid to the current user id.
     $this->currentuserid = self::$loadeduserid;
     parent::__construct($definition, $store, $loader);
     // This will trigger check tracked user. If this gets removed a call to that will need to be added here in its place.
     $this->set(self::LASTACCESS, cache::now());
     if ($definition->has_invalidation_events()) {
         $lastinvalidation = $this->get('lastsessioninvalidation');
         if ($lastinvalidation === false) {
             // This is a new session, there won't be anything to invalidate. Set the time of the last invalidation and
             // move on.
             $this->set('lastsessioninvalidation', cache::now());
             return;
         } else {
             if ($lastinvalidation == cache::now()) {
                 // We've already invalidated during this request.
                 return;
             }
         }
         // Get the event invalidation cache.
         $cache = cache::make('core', 'eventinvalidation');
         $events = $cache->get_many($definition->get_invalidation_events());
         $todelete = array();
         $purgeall = false;
         // Iterate the returned data for the events.
         foreach ($events as $event => $keys) {
             if ($keys === false) {
                 // No data to be invalidated yet.
                 continue;
             }
             // Look at each key and check the timestamp.
             foreach ($keys as $key => $timestamp) {
                 // If the timestamp of the event is more than or equal to the last invalidation (happened between the last
                 // invalidation and now)then we need to invaliate the key.
                 if ($timestamp >= $lastinvalidation) {
                     if ($key === 'purged') {
                         $purgeall = true;
                         break;
                     } else {
                         $todelete[] = $key;
                     }
                 }
             }
         }
         if ($purgeall) {
             $this->purge();
         } else {
             if (!empty($todelete)) {
                 $todelete = array_unique($todelete);
                 $this->delete_many($todelete);
             }
         }
         // Set the time of the last invalidation.
         $this->set('lastsessioninvalidation', cache::now());
     }
 }
開發者ID:masaterutakeno,項目名稱:MoodleMobile,代碼行數:71,代碼來源:loaders.php

示例2: __construct

 /**
  *
  * @param string $id page id
  * @param string $file source file for cache
  * @param string $mode input mode
  */
 public function __construct($id, $file, $mode)
 {
     if ($id) {
         $this->page = $id;
     }
     $this->file = $file;
     $this->mode = $mode;
     parent::__construct($file . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.' . $mode);
 }
開發者ID:kevinlovesing,項目名稱:dokuwiki,代碼行數:15,代碼來源:cache.php

示例3: __construct

 /**
  * Override the cache::construct method.
  *
  * This function gets overriden so that we can process any invalidation events if need be.
  * If the definition doesn't have any invalidation events then this occurs exactly as it would for the cache class.
  * Otherwise we look at the last invalidation time and then check the invalidation data for events that have occured
  * between then now.
  *
  * You should not call this method from your code, instead you should use the cache::make methods.
  *
  * @param cache_definition $definition
  * @param cache_store $store
  * @param cache_loader|cache_data_source $loader
  * @return void
  */
 public function __construct(cache_definition $definition, cache_store $store, $loader = null)
 {
     parent::__construct($definition, $store, $loader);
     if ($definition->has_invalidation_events()) {
         $lastinvalidation = $this->get('lastsessioninvalidation');
         if ($lastinvalidation === false) {
             // This is a new session, there won't be anything to invalidate. Set the time of the last invalidation and
             // move on.
             $this->set('lastsessioninvalidation', cache::now());
             return;
         } else {
             if ($lastinvalidation == cache::now()) {
                 // We've already invalidated during this request.
                 return;
             }
         }
         // Get the event invalidation cache.
         $cache = cache::make('core', 'eventinvalidation');
         $events = $cache->get_many($definition->get_invalidation_events());
         $todelete = array();
         // Iterate the returned data for the events.
         foreach ($events as $event => $keys) {
             if ($keys === false) {
                 // No data to be invalidated yet.
                 continue;
             }
             // Look at each key and check the timestamp.
             foreach ($keys as $key => $timestamp) {
                 // If the timestamp of the event is more than or equal to the last invalidation (happened between the last
                 // invalidation and now)then we need to invaliate the key.
                 if ($timestamp >= $lastinvalidation) {
                     $todelete[] = $key;
                 }
             }
         }
         if (!empty($todelete)) {
             $todelete = array_unique($todelete);
             $this->delete_many($todelete);
         }
         // Set the time of the last invalidation.
         $this->set('lastsessioninvalidation', cache::now());
     }
 }
開發者ID:Burick,項目名稱:moodle,代碼行數:58,代碼來源:loaders.php

示例4: __construct

 public function __construct($config)
 {
     $this->config_data = $config;
     parent::__construct($config);
     $this->config($config);
 }
開發者ID:joyerma,項目名稱:yongzhuo,代碼行數:6,代碼來源:memcache.php

示例5: __construct

 public function __construct()
 {
     $this->host = new Memcache();
     $this->host->pconnect(defined('MEMCACHE_HOST') ? MEMCACHE_HOST : 'localhost');
     parent::__construct();
 }
開發者ID:umonkey,項目名稱:molinos-cms,代碼行數:6,代碼來源:class.cache.php


注:本文中的cache::__construct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。