Esempio n. 1
0
 public function testGetConfigCaching()
 {
     $reflectedClass = new ReflectionClass('CM_Class_Abstract');
     $configCacheList = $reflectedClass->getProperty('_classConfigList');
     $configCacheList->setAccessible(true);
     CM_Config::get()->CM_Class_Implementation = new stdClass();
     CM_Config::get()->CM_Class_Implementation->foo = 'foo';
     $this->assertSame('foo', CM_Class_Implementation::getConfig()->foo);
     CM_Config::get()->CM_Class_Implementation->foo = 'bar';
     $this->assertSame('foo', CM_Class_Implementation::getConfig()->foo);
     $configCacheList->setValue([]);
     $this->assertSame('foo', CM_Class_Implementation::getConfig()->foo);
     $cache = new CM_Cache_Storage_Apc();
     $cache->flush();
     $this->assertSame('foo', CM_Class_Implementation::getConfig()->foo);
     $configCacheList->setValue([]);
     $this->assertSame('bar', CM_Class_Implementation::getConfig()->foo);
 }
Esempio n. 2
0
 /**
  * @deprecated Configuration should not be accessed by class, rather register a service with configuration
  *
  * @return stdClass
  * @throws CM_Exception_Invalid
  */
 protected static function _getConfig()
 {
     if (null === self::$_classConfigCacheEnabled) {
         self::$_classConfigCacheEnabled = CM_Config::get()->classConfigCacheEnabled;
     }
     $calledClass = get_called_class();
     $cacheKey = CM_CacheConst::ClassConfig . '_className:' . $calledClass;
     $cache = new CM_Cache_Storage_Apc();
     if (!self::$_classConfigCacheEnabled || !isset(self::$_classConfigList[$calledClass])) {
         if (!self::$_classConfigCacheEnabled || false === ($result = $cache->get($cacheKey))) {
             $result = self::_getConfigRaw();
             if (self::$_classConfigCacheEnabled) {
                 $cache->set($cacheKey, $result);
             }
         }
         self::$_classConfigList[$calledClass] = $result;
     }
     return self::$_classConfigList[$calledClass];
 }
Esempio n. 3
0
 public function ajax_clearCache(CM_Params $params, CM_Frontend_JavascriptContainer_View $handler, CM_Http_Response_View_Ajax $response)
 {
     $cachesCleared = array();
     if ($params->getBoolean('CM_Cache_Storage_Memcache', false)) {
         $cache = new CM_Cache_Storage_Memcache();
         $cache->flush();
         $cachesCleared[] = 'CM_Cache_Storage_Memcache';
     }
     if ($params->getBoolean('CM_Cache_Storage_Apc', false)) {
         $cache = new CM_Cache_Storage_Apc();
         $cache->flush();
         $cachesCleared[] = 'CM_Cache_Storage_Apc';
     }
     if ($params->getBoolean('CM_Cache_Storage_File', false)) {
         $cache = new CM_Cache_Storage_File();
         $cache->flush();
         $cachesCleared[] = 'CM_Cache_Storage_File';
     }
     $handler->message('Cleared: ' . implode(', ', $cachesCleared));
 }
Esempio n. 4
0
 /**
  * @return array
  */
 private function _getModulePaths()
 {
     $cacheKey = CM_CacheConst::Modules;
     $apcCache = new CM_Cache_Storage_Apc();
     if (false === ($modulePaths = $apcCache->get($cacheKey))) {
         $fileCache = new CM_Cache_Storage_File();
         $installation = new CM_App_Installation(DIR_ROOT);
         if ($installation->getUpdateStamp() > $fileCache->getCreateStamp($cacheKey) || false === ($modulePaths = $fileCache->get($cacheKey))) {
             $modulePaths = $installation->getModulePaths();
             $fileCache->set($cacheKey, $modulePaths);
         }
         $apcCache->set($cacheKey, $modulePaths);
     }
     return $modulePaths;
 }