Пример #1
0
 /**
  * Parse the given template and return it.
  *
  * Will cache the results for one call.
  *
  * @param string $templatePathAndFilename absolute filename of the template to be parsed
  * @return Tx_Fluid_Core_Parser_ParsedTemplateInterface the parsed template tree
  * @throws Tx_Fluid_View_Exception_InvalidTemplateResourceException
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 protected function parseTemplate($templatePathAndFilename)
 {
     $cacheIdentifier = md5($templatePathAndFilename);
     if (!$this->cache->has($cacheIdentifier)) {
         $parsedTemplate = parent::parseTemplate($templatePathAndFilename);
         $this->cache->set($cacheIdentifier, $parsedTemplate);
     } else {
         $parsedTemplate = $this->cache->get($cacheIdentifier);
     }
     return $parsedTemplate;
 }
Пример #2
0
 /**
  * Exports the internal reflection data into the ReflectionData cache.
  *
  * @return void
  */
 protected function saveToCache()
 {
     if (!is_object($this->dataCache)) {
         throw new Tx_Extbase_Reflection_Exception('A cache must be injected before initializing the Reflection Service.', 1232044697);
     }
     $data = array();
     $propertyNames = array('reflectedClassNames', 'classPropertyNames', 'classTagsValues', 'methodTagsValues', 'methodParameters', 'propertyTagsValues', 'taggedClasses', 'classSchemata');
     foreach ($propertyNames as $propertyName) {
         $data[$propertyName] = $this->{$propertyName};
     }
     $this->dataCache->set($this->cacheIdentifier, $data);
 }
Пример #3
0
 /**
  * Creates a SELECT prepared SQL statement.
  *
  * @param string See exec_SELECTquery()
  * @param string See exec_SELECTquery()
  * @param string See exec_SELECTquery()
  * @param string See exec_SELECTquery()
  * @param string See exec_SELECTquery()
  * @param string See exec_SELECTquery()
  * @param array $input_parameters An array of values with as many elements as there are bound parameters in the SQL statement being executed. All values are treated as t3lib_db_PreparedStatement::PARAM_AUTOTYPE.
  * @return t3lib_db_PreparedStatement Prepared statement
  */
 public function prepare_SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy = '', $limit = '', array $input_parameters = array())
 {
     if ($this->debug) {
         $pt = t3lib_div::milliseconds();
     }
     $precompiledParts = array();
     if ($this->queryCache) {
         $cacheKey = 'prepare_SELECTquery-' . tx_dbal_querycache::getCacheKey(array('selectFields' => $select_fields, 'fromTable' => $from_table, 'whereClause' => $where_clause, 'groupBy' => $groupBy, 'orderBy' => $orderBy, 'limit' => $limit));
         if ($this->queryCache->has($cacheKey)) {
             $precompiledParts = $this->queryCache->get($cacheKey);
             if ($this->debug) {
                 $data = array('args' => array($from_table, $select_fields, $where_clause, $groupBy, $orderBy, $limit, $input_parameters), 'precompiledParts' => $precompiledParts);
                 $this->debugHandler('prepare_SELECTquery (cache hit)', t3lib_div::milliseconds() - $pt, $data);
             }
         }
     }
     if (count($precompiledParts) == 0) {
         // Map table / field names if needed:
         $ORIG_tableName = $from_table;
         // Saving table names in $ORIG_from_table since $from_table is transformed beneath:
         $parsedFromTable = array();
         $queryComponents = array();
         if ($tableArray = $this->map_needMapping($ORIG_tableName, FALSE, $parsedFromTable)) {
             $from = $parsedFromTable ? $parsedFromTable : $from_table;
             $components = $this->map_remapSELECTQueryParts($select_fields, $from, $where_clause, $groupBy, $orderBy);
             $queryComponents['SELECT'] = $components[0];
             $queryComponents['FROM'] = $components[1];
             $queryComponents['WHERE'] = $components[2];
             $queryComponents['GROUPBY'] = $components[3];
             $queryComponents['ORDERBY'] = $components[4];
             $queryComponents['parameters'] = $components[5];
         } else {
             $queryComponents = $this->getQueryComponents($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit);
         }
         $queryComponents['ORIG_tableName'] = $ORIG_tableName;
         if (!$this->runningNative()) {
             // Quotes all fields
             $queryComponents['SELECT'] = $this->_quoteFieldNames($queryComponents['SELECT']);
             $queryComponents['FROM'] = $this->_quoteFromTables($queryComponents['FROM']);
             $queryComponents['WHERE'] = $this->_quoteWhereClause($queryComponents['WHERE']);
             $queryComponents['GROUPBY'] = $this->_quoteGroupBy($queryComponents['GROUPBY']);
             $queryComponents['ORDERBY'] = $this->_quoteOrderBy($queryComponents['ORDERBY']);
         }
         $precompiledParts = $this->precompileSELECTquery($queryComponents);
         if ($this->queryCache) {
             try {
                 $this->queryCache->set($cacheKey, $precompiledParts);
             } catch (t3lib_cache_Exception $e) {
                 if ($this->debug) {
                     t3lib_div::devLog($e->getMessage(), 'dbal', 1);
                 }
             }
         }
     }
     $preparedStatement = t3lib_div::makeInstance('t3lib_db_PreparedStatement', '', $from_table, $precompiledParts);
     /* @var $preparedStatement t3lib_db_PreparedStatement */
     // Bind values to parameters
     foreach ($input_parameters as $key => $value) {
         $preparedStatement->bindValue($key, $value, t3lib_db_PreparedStatement::PARAM_AUTOTYPE);
     }
     if ($this->debug) {
         $data = array('args' => array($from_table, $select_fields, $where_clause, $groupBy, $orderBy, $limit, $input_parameters), 'ORIG_from_table' => $ORIG_tableName);
         $this->debugHandler('prepare_SELECTquery', t3lib_div::milliseconds() - $pt, $data);
     }
     // Return prepared statement
     return $preparedStatement;
 }
 /**
  * @test
  * @author Karsten Dambekalns <*****@*****.**>
  * @author Ingo Renner <*****@*****.**>
  */
 public function getByTagCallsBackend()
 {
     $tag = 'sometag';
     $identifiers = array('one', 'two');
     $entries = array('one value', 'two value');
     $backend = $this->getMock('t3lib_cache_backend_AbstractBackend', array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'findIdentifiersByTags', 'flush', 'flushByTag', 'flushByTags', 'collectGarbage'), array(), '', FALSE);
     $backend->expects($this->once())->method('findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers));
     $backend->expects($this->exactly(2))->method('get')->will($this->onConsecutiveCalls(serialize('one value'), serialize('two value')));
     $cache = new t3lib_cache_frontend_VariableFrontend('VariableFrontend', $backend);
     $this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries');
 }
Пример #5
0
 /**
  * sets the cache for the id
  *
  * @param $id
  * @param $value
  */
 public function set($id, $value)
 {
     $this->level1Cache[$id] = $value;
     $this->level2Cache->set($id, $value);
 }