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


PHP Cache::enabled方法代碼示例

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


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

示例1: beforeLayout

 /**
  * Callback for Helper::beforeLayout
  *
  * @param Event $view Event
  * @param string $layoutFile layout file name
  *
  * @return bool true
  */
 public function beforeLayout(Event $event, $layoutFile)
 {
     if (!Cache::enabled()) {
         $this->config('disable', true);
     } elseif (!$this->request->is('get')) {
         $this->config('disable', true);
     } elseif ($this->request->session()->check('Flash')) {
         $this->config('disable', true);
     } elseif ($this->_View->get(ViewMemcachedHelper::NOCACHE)) {
         $this->config('disable', true);
     }
     if ($this->_View->get(ViewMemcachedHelper::DELETE) === true) {
         Cache::delete($this->config('cacheKey'), $this->config('cacheConfig'));
     }
     return true;
 }
開發者ID:chnvcode,項目名稱:cakephp-viewmemcached,代碼行數:24,代碼來源:ViewMemcachedHelper.php

示例2: cache

 /**
  * Reads/writes temporary data to cache files or session.
  *
  * @param string $path File path within /tmp to save the file.
  * @param mixed $data The data to save to the temporary file.
  * @param mixed $expires A valid strtotime string when the data expires.
  * @param string $target The target of the cached data; either 'cache' or 'public'.
  * @return mixed The contents of the temporary file.
  * @deprecated Will be removed in 3.0. Please use Cache::write() instead.
  */
 function cache($path, $data = null, $expires = '+1 day', $target = 'cache')
 {
     if (!Cache::enabled()) {
         return null;
     }
     $now = time();
     if (!is_numeric($expires)) {
         $expires = strtotime($expires, $now);
     }
     switch (strtolower($target)) {
         case 'cache':
             $filename = CACHE . $path;
             break;
         case 'public':
             $filename = WWW_ROOT . $path;
             break;
         case 'tmp':
             $filename = TMP . $path;
             break;
     }
     $timediff = $expires - $now;
     $filetime = false;
     if (file_exists($filename)) {
         //@codingStandardsIgnoreStart
         $filetime = @filemtime($filename);
         //@codingStandardsIgnoreEnd
     }
     if ($data === null) {
         if (file_exists($filename) && $filetime !== false) {
             if ($filetime + $timediff < $now) {
                 //@codingStandardsIgnoreStart
                 @unlink($filename);
                 //@codingStandardsIgnoreEnd
             } else {
                 //@codingStandardsIgnoreStart
                 $data = @file_get_contents($filename);
                 //@codingStandardsIgnoreEnd
             }
         }
     } elseif (is_writable(dirname($filename))) {
         //@codingStandardsIgnoreStart
         @file_put_contents($filename, $data, LOCK_EX);
         //@codingStandardsIgnoreEnd
     }
     return $data;
 }
開發者ID:ripzappa0924,項目名稱:carte0.0.1,代碼行數:56,代碼來源:basics.php

示例3: testEnableDisableEnabled

 /**
  * Test toggling enabled state of cache.
  *
  * @return void
  */
 public function testEnableDisableEnabled()
 {
     $this->assertNull(Cache::enable());
     $this->assertTrue(Cache::enabled(), 'Should be on');
     $this->assertNull(Cache::disable());
     $this->assertFalse(Cache::enabled(), 'Should be off');
 }
開發者ID:maitrepylos,項目名稱:nazeweb,代碼行數:12,代碼來源:CacheTest.php

示例4: tmpViewer

 /**
  * Temporary files viewer (assets, cache, logs, sitemap and thumbnails)
  * @return void
  */
 public function tmpViewer()
 {
     $assetsSize = (new Folder(Configure::read('Assets.target')))->dirsize();
     $cacheSize = (new Folder(CACHE))->dirsize();
     $logsSize = (new Folder(LOGS))->dirsize();
     $sitemapSize = is_readable(SITEMAP) ? filesize(SITEMAP) : 0;
     $thumbsSize = (new Folder(Configure::read('Thumbs.target')))->dirsize();
     $this->set(am(['cacheStatus' => Cache::enabled(), 'totalSize' => $assetsSize + $cacheSize + $logsSize + $sitemapSize + $thumbsSize], compact('assetsSize', 'cacheSize', 'logsSize', 'sitemapSize', 'thumbsSize')));
 }
開發者ID:mirko-pagliai,項目名稱:me-cms,代碼行數:13,代碼來源:SystemsController.php


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