93 parent::setCache($cache);
95 $this->tagsTable =
'cf_' . $this->cacheIdentifier .
'_tags';
105 $this->identifierField = $this->cacheTable .
'.identifier';
106 $this->expiresField = $this->cacheTable .
'.expires';
107 $this->maximumLifetime = self::FAKED_UNLIMITED_EXPIRE -
$GLOBALS[
'EXEC_TIME'];
109 $this->tableJoin = $this->identifierField .
' = ' . $this->tagsTable .
'.identifier';
110 $this->expiredStatement = $this->expiresField .
' < ' . $GLOBALS[
'EXEC_TIME'];
111 $this->notExpiredStatement = $this->expiresField .
' >= ' . $GLOBALS[
'EXEC_TIME'];
125 public function set($entryIdentifier, $data, array $tags = array(), $lifetime = NULL) {
127 if (!is_string($data)) {
128 throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException(
129 'The specified data is of type "' . gettype($data) .
'" but a string is expected.',
133 if (is_null($lifetime)) {
136 if ($lifetime === 0 || $lifetime > $this->maximumLifetime) {
139 $expires =
$GLOBALS[
'EXEC_TIME'] + $lifetime;
140 $this->
remove($entryIdentifier);
141 if ($this->compression) {
142 $data = gzcompress($data, $this->compressionLevel);
144 $GLOBALS[
'TYPO3_DB']->exec_INSERTquery($this->cacheTable, array(
145 'identifier' => $entryIdentifier,
146 'expires' => $expires,
151 $fields[] =
'identifier';
154 foreach ($tags as $tag) {
156 $tagRow[] = $entryIdentifier;
158 $tagRows[] = $tagRow;
160 $GLOBALS[
'TYPO3_DB']->exec_INSERTmultipleRows($this->tagsTable, $fields, $tagRows);
170 public function get($entryIdentifier) {
173 $cacheEntry =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
176 'identifier = ' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($entryIdentifier, $this->cacheTable) .
' AND ' . $this->notExpiredStatement
178 if (is_array($cacheEntry)) {
179 $cacheEntry = $cacheEntry[
'content'];
181 if ($this->compression && strlen($cacheEntry)) {
182 $cacheEntry = gzuncompress($cacheEntry);
184 return $cacheEntry !== NULL ? $cacheEntry : FALSE;
193 public function has($entryIdentifier) {
196 $cacheEntries =
$GLOBALS[
'TYPO3_DB']->exec_SELECTcountRows(
199 'identifier = ' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($entryIdentifier, $this->cacheTable) .
' AND ' . $this->notExpiredStatement
201 if ($cacheEntries >= 1) {
214 public function remove($entryIdentifier) {
216 $entryRemoved = FALSE;
217 $GLOBALS[
'TYPO3_DB']->exec_DELETEquery(
219 'identifier = ' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($entryIdentifier, $this->cacheTable)
223 $affectedRows =
$GLOBALS[
'TYPO3_DB']->sql_affected_rows();
224 $GLOBALS[
'TYPO3_DB']->exec_DELETEquery(
226 'identifier = ' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($entryIdentifier, $this->tagsTable)
228 if ($affectedRows == 1) {
229 $entryRemoved = TRUE;
231 return $entryRemoved;
242 $cacheEntryIdentifiers = array();
243 $cacheEntryIdentifierRows =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
244 $this->identifierField,
246 $this->tagsTable .
'.tag = ' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($tag, $this->tagsTable) .
' AND ' . $this->tableJoin .
' AND ' . $this->notExpiredStatement,
247 $this->identifierField
249 foreach ($cacheEntryIdentifierRows as $cacheEntryIdentifierRow) {
250 $cacheEntryIdentifiers[$cacheEntryIdentifierRow[
'identifier']] = $cacheEntryIdentifierRow[
'identifier'];
252 return $cacheEntryIdentifiers;
262 $GLOBALS[
'TYPO3_DB']->exec_TRUNCATEquery($this->cacheTable);
263 $GLOBALS[
'TYPO3_DB']->exec_TRUNCATEquery($this->tagsTable);
277 DELETE tags2, cache1' 278 .
' FROM ' . $this->tagsTable .
' AS tags1' 279 .
' JOIN ' . $this->tagsTable .
' AS tags2 ON tags1.identifier = tags2.identifier' 280 .
' JOIN ' . $this->cacheTable .
' AS cache1 ON tags1.identifier = cache1.identifier' 281 .
' WHERE tags1.tag = ' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($tag, $this->tagsTable)
284 $tagsTableWhereClause = $this->tagsTable .
'.tag = ' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($tag, $this->tagsTable);
285 $cacheEntryIdentifierRowsResource =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'DISTINCT identifier', $this->tagsTable, $tagsTableWhereClause);
286 $cacheEntryIdentifiers = array();
287 while ($cacheEntryIdentifierRow =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($cacheEntryIdentifierRowsResource)) {
288 $cacheEntryIdentifiers[] =
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($cacheEntryIdentifierRow[
'identifier'], $this->cacheTable);
290 $GLOBALS[
'TYPO3_DB']->sql_free_result($cacheEntryIdentifierRowsResource);
291 if (!empty($cacheEntryIdentifiers)) {
292 $deleteWhereClause =
'identifier IN (' . implode(
', ', $cacheEntryIdentifiers) .
')';
293 $GLOBALS[
'TYPO3_DB']->exec_DELETEquery($this->cacheTable, $deleteWhereClause);
294 $GLOBALS[
'TYPO3_DB']->exec_DELETEquery($this->tagsTable, $deleteWhereClause);
311 .
' FROM ' . $this->cacheTable .
' AS cache' 312 .
' LEFT OUTER JOIN ' . $this->tagsTable .
' AS tags ON cache.identifier = tags.identifier' 313 .
' WHERE cache.expires < ' .
$GLOBALS[
'EXEC_TIME']
316 $GLOBALS[
'TYPO3_DB']->sql_query(
318 .
' FROM ' . $this->tagsTable .
' AS tags' 319 .
' LEFT OUTER JOIN ' . $this->cacheTable .
' AS cache ON tags.identifier = cache.identifier' 320 .
' WHERE cache.identifier IS NULL' 324 $cacheEntryIdentifierRowsResource =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'DISTINCT identifier', $this->cacheTable,
'expires < ' .
$GLOBALS[
'EXEC_TIME']);
325 $cacheEntryIdentifiers = array();
326 while ($cacheEntryIdentifierRow =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($cacheEntryIdentifierRowsResource)) {
327 $cacheEntryIdentifiers[] =
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($cacheEntryIdentifierRow[
'identifier'], $this->tagsTable);
329 $GLOBALS[
'TYPO3_DB']->sql_free_result($cacheEntryIdentifierRowsResource);
331 if (!empty($cacheEntryIdentifiers)) {
332 $GLOBALS[
'TYPO3_DB']->exec_DELETEquery($this->tagsTable,
'identifier IN (' . implode(
', ', $cacheEntryIdentifiers) .
')');
335 $GLOBALS[
'TYPO3_DB']->exec_DELETEquery($this->cacheTable,
'expires < ' .
$GLOBALS[
'EXEC_TIME']);
339 'SELECT tags.identifier' 340 .
' FROM ' . $this->tagsTable .
' AS tags' 341 .
' LEFT OUTER JOIN ' . $this->cacheTable .
' AS cache ON tags.identifier = cache.identifier' 342 .
' WHERE cache.identifier IS NULL' 343 .
' GROUP BY tags.identifier' 347 $tagsEntryIdentifiers[] =
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($row[
'identifier'], $this->tagsTable);
350 if (!empty($tagsEntryIdentifiers)) {
353 .
' FROM ' . $this->tagsTable
354 .
' WHERE identifier IN (' . implode(
',', $tagsEntryIdentifiers) .
')' 409 if (!$this->cache instanceof \
TYPO3\CMS\Core\
Cache\Frontend\FrontendInterface) {
410 throw new \TYPO3\CMS\Core\Cache\Exception(
'No cache frontend has been set via setCache() yet.', 1236518288);
422 $cacheTableSql = file_get_contents(
423 \
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'core') .
424 'Resources/Private/Sql/Cache/Backend/Typo3DatabaseBackendCache.sql' 426 $requiredTableStructures = str_replace(
'###CACHE_TABLE###', $this->cacheTable, $cacheTableSql) . LF . LF;
427 $tagsTableSql = file_get_contents(
428 \
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'core') .
429 'Resources/Private/Sql/Cache/Backend/Typo3DatabaseBackendTags.sql' 431 $requiredTableStructures .= str_replace(
'###TAGS_TABLE###', $this->tagsTable, $tagsTableSql) . LF;
432 return $requiredTableStructures;
443 return !((bool)\
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'dbal'));
throwExceptionIfFrontendDoesNotExist()
setCompressionLevel($compressionLevel)
setCache(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache)
const FAKED_UNLIMITED_EXPIRE
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
initializeCommonReferences()
findIdentifiersByTag($tag)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
setCompression($compression)