Ejemplo n.º 1
0
 /**
  * Tries to load the reflection data from this service's cache.
  *
  * @return void
  */
 protected function loadFromCache()
 {
     if ($this->dataCache->has($this->cacheIdentifier)) {
         $data = $this->dataCache->get($this->cacheIdentifier);
         foreach ($data as $propertyName => $propertyValue) {
             $this->{$propertyName} = $propertyValue;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Tries to load the reflection data from this service's cache.
  *
  * @return void
  */
 protected function loadFromCache()
 {
     $cacheKey = $this->getCacheKey();
     if ($this->cache->has($cacheKey)) {
         $data = $this->cache->get($cacheKey);
         foreach ($data as $propertyName => $propertyValue) {
             $this->{$propertyName} = $propertyValue;
         }
     }
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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 Robert Lemke <*****@*****.**>
  * @author Ingo Renner <*****@*****.**>
  */
 public function hasReturnsResultFromBackend()
 {
     $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('has')->with($this->equalTo('VariableCacheTest'))->will($this->returnValue(TRUE));
     $cache = new t3lib_cache_frontend_VariableFrontend('VariableFrontend', $backend);
     $this->assertTrue($cache->has('VariableCacheTest'), 'has() did not return TRUE.');
 }
Ejemplo n.º 6
0
 /**
  * checks if cacheentry exists for id
  * @param string $id
  */
 public function has($id)
 {
     return isset($this->level1Cache[$id]) || $this->level2Cache->has($id);
 }