Пример #1
0
 /**
  * @covers Xoops\Core\Cache\CacheManager::getCache
  */
 public function testGetCache()
 {
     $pool1 = $this->object->getCache('default');
     $this->assertInstanceOf('Xoops\\Core\\Cache\\Access', $pool1);
     $pool2 = $this->object->getCache('nosuchpooldefinition');
     $this->assertInstanceOf('Xoops\\Core\\Cache\\Access', $pool2);
     $this->assertSame($pool1, $pool2);
 }
 /**
  * Get schema SQL of required cache framework tables.
  *
  * This method needs ext_localconf and ext_tables loaded!
  *
  * @return string Cache framework SQL
  */
 public function getCachingFrameworkRequiredDatabaseSchema()
 {
     // Use new to circumvent the singleton pattern of CacheManager
     $cacheManager = new CacheManager();
     $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
     // Cache manager needs cache factory. cache factory injects itself to manager in __construct()
     new CacheFactory('production', $cacheManager);
     $tableDefinitions = '';
     foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] as $cacheName => $_) {
         $backend = $cacheManager->getCache($cacheName)->getBackend();
         if (method_exists($backend, 'getTableDefinitions')) {
             $tableDefinitions .= LF . $backend->getTableDefinitions();
         }
     }
     return $tableDefinitions;
 }
Пример #3
0
<?php

/**
 * General example for the Cache component.
 *
 * @package Cache
 * @version 1.4.1
 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */
/**
 * Content view
 */
// Assuming that the ContentView cache has been initialized correctly in the
// index.php:
// First retreive tha cache you want to access from the manager.
$cache = CacheManager::getCache('ContentView');
// Prepare your data identification, use some attributes and a unique ID
$attributes = array('user' => $user, 'nodeid' => $NodeID, 'offset' => $Offset, 'layout' => $layout, 'lang' => $LanguageCode, 'vmode' => $ViewMode);
$id = getUniqueId($attributes, $viewParameters);
// Initialize data and try to grep from cache
$data = '';
if (($data = $cache->restore($id, $attributes)) === false) {
    // No data in cache or data has expired. Generate new data...
    // What ever exactly happens to create it in eZp.
    $data = generateMyData();
    // ... and store it inside the cache
    $cache->store($id, $attributes, $data);
}
// And that's all! : )
Пример #4
0
 /**
  * gets the cache from the cacheManager
  * 
  * @return array
  */
 public function getRoutingData()
 {
     return $this->manager->getCache();
 }