当前位置: 首页>>代码示例>>PHP>>正文


PHP Tinebase_Core::cacheStatus方法代码示例

本文整理汇总了PHP中Tinebase_Core::cacheStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Core::cacheStatus方法的具体用法?PHP Tinebase_Core::cacheStatus怎么用?PHP Tinebase_Core::cacheStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tinebase_Core的用法示例。


在下文中一共展示了Tinebase_Core::cacheStatus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setupCache

 /**
  * setup the cache and add it to zend registry
  *
  * @param bool $_enabled disabled cache regardless what's configured in config.inc.php
  * 
  * @todo use the same config keys as Zend_Cache (backend + frontend) to simplify this
  */
 public static function setupCache($_enabled = true)
 {
     if (self::$cacheStatus !== NULL && self::$cacheStatus === $_enabled) {
         return;
     }
     $config = self::getConfig();
     if ($config->caching && $config->caching->active) {
         if (isset($config->caching->shared) && $config->caching->shared === true) {
             self::set(self::SHAREDCACHE, true);
         } else {
             self::set(self::SHAREDCACHE, false);
         }
     }
     // create zend cache
     if ($_enabled === true && $config->caching && $config->caching->active) {
         $logging = $config->caching->logging ? $config->caching->logging : false;
         $logger = self::getLogger();
         $frontendOptions = array('lifetime' => $config->caching->lifetime ? $config->caching->lifetime : 7200, 'automatic_serialization' => true, 'caching' => true, 'automatic_cleaning_factor' => 0, 'write_control' => false, 'logging' => $logging, 'logger' => $logger);
         $backendType = $config->caching->backend ? ucfirst($config->caching->backend) : 'File';
         $backendOptions = $config->caching->backendOptions ? $config->caching->backendOptions->toArray() : false;
         if (!$backendOptions) {
             switch ($backendType) {
                 case 'File':
                     $backendOptions = array('cache_dir' => $config->caching->path ? $config->caching->path : Tinebase_Core::getTempDir(), 'hashed_directory_level' => $config->caching->dirlevel ? $config->caching->dirlevel : 4, 'logging' => $logging, 'logger' => $logger);
                     break;
                 case 'Memcached':
                     $host = $config->caching->host ? $config->caching->host : (isset($config->caching->memcached->host) ? $config->caching->memcached->host : 'localhost');
                     $port = $config->caching->port ? $config->caching->port : (isset($config->caching->memcached->port) ? $config->caching->memcached->port : 11211);
                     $backendOptions = array('servers' => array('host' => $host, 'port' => $port, 'persistent' => TRUE));
                     break;
                 case 'Redis':
                     $host = $config->caching->host ? $config->caching->host : ($config->caching->redis->host ? $config->caching->redis->host : 'localhost');
                     $port = $config->caching->port ? $config->caching->port : ($config->caching->redis->port ? $config->caching->redis->port : 6379);
                     if ($config->caching && $config->caching->prefix) {
                         $prefix = $config->caching->prefix;
                     } else {
                         if ($config->caching && $config->caching->redis && $config->caching->redis->prefix) {
                             $prefix = $config->caching->redis->prefix;
                         } else {
                             $prefix = $config->database && $config->database->tableprefix ? $config->database->tableprefix : 'tine20';
                         }
                     }
                     $prefix .= '_CACHE_';
                     $backendOptions = array('servers' => array('host' => $host, 'port' => $port, 'prefix' => $prefix));
                     break;
                 default:
                     $backendOptions = array();
                     break;
             }
         }
         Tinebase_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . " cache of backend type '{$backendType}' enabled");
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             // logger is an object, that makes ugly traces :)
             $backendOptionsWithoutLogger = $backendOptions;
             if (isset($backendOptionsWithoutLogger['logger'])) {
                 unset($backendOptionsWithoutLogger['logger']);
             }
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " backend options: " . print_r($backendOptionsWithoutLogger, TRUE));
         }
     } else {
         Tinebase_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . ' Cache disabled');
         $backendType = 'Test';
         $frontendOptions = array('caching' => false);
         $backendOptions = array();
     }
     // getting a Zend_Cache_Core object
     try {
         $cache = Zend_Cache::factory('Core', $backendType, $frontendOptions, $backendOptions);
     } catch (Exception $e) {
         Tinebase_Exception::log($e);
         $enabled = false;
         if ('File' === $backendType && !is_dir($backendOptions['cache_dir'])) {
             Tinebase_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . ' Create cache directory and re-try');
             if (mkdir($backendOptions['cache_dir'], 0770, true)) {
                 $enabled = $_enabled;
             }
         }
         self::setupCache($enabled);
         return;
     }
     // some important caches
     Zend_Locale::setCache($cache);
     Zend_Translate::setCache($cache);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     self::set(self::CACHE, $cache);
     self::$cacheStatus = $_enabled;
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:94,代码来源:Core.php

示例2: getCache

 /**
  * get cache from the registry
  *
  * @return Zend_Cache_Core the cache
  */
 public static function getCache()
 {
     if (!self::get(self::CACHE) instanceof Zend_Cache_Core) {
         self::$cacheStatus = null;
         Tinebase_Core::setupCache();
     }
     return self::get(self::CACHE);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:13,代码来源:Core.php


注:本文中的Tinebase_Core::cacheStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。