当前位置: 首页>>代码示例>>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;未经允许,请勿转载。