58 $this->dataSourceName = $DSN;
105 public function set($entryIdentifier, $data, array $tags = array(), $lifetime = NULL) {
106 if (!$this->cache instanceof \
TYPO3\CMS\Core\
Cache\Frontend\FrontendInterface) {
107 throw new \TYPO3\CMS\Core\Cache\Exception(
'No cache frontend has been set yet via setCache().', 1259515600);
109 if (!is_string($data)) {
110 throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException(
'The specified data is of type "' . gettype($data) .
'" but a string is expected.', 1259515601);
112 $this->
remove($entryIdentifier);
113 $lifetime = $lifetime === NULL ? $this->defaultLifetime : $lifetime;
114 $statementHandle = $this->databaseHandle->prepare(
'INSERT INTO "cache" ("identifier", "context", "cache", "created", "lifetime", "content") VALUES (?, ?, ?, ?, ?, ?)');
115 $result = $statementHandle->execute(array($entryIdentifier, $this->context, $this->cacheIdentifier,
$GLOBALS[
'EXEC_TIME'], $lifetime, $data));
117 throw new \TYPO3\CMS\Core\Cache\Exception(
'The cache entry "' . $entryIdentifier .
'" could not be written.', 1259530791);
119 $statementHandle = $this->databaseHandle->prepare(
'INSERT INTO "tags" ("identifier", "context", "cache", "tag") VALUES (?, ?, ?, ?)');
120 foreach ($tags as $tag) {
121 $result = $statementHandle->execute(array($entryIdentifier, $this->context, $this->cacheIdentifier, $tag));
123 throw new \TYPO3\CMS\Core\Cache\Exception(
'The tag "' . $tag .
' for cache entry "' . $entryIdentifier .
'" could not be written.', 1259530751);
135 public function get($entryIdentifier) {
136 $statementHandle = $this->databaseHandle->prepare(
'SELECT "content" FROM "cache" WHERE "identifier"=? AND "context"=? AND "cache"=?' . $this->
getNotExpiredStatement());
137 $statementHandle->execute(array($entryIdentifier, $this->context, $this->cacheIdentifier));
138 return $statementHandle->fetchColumn();
148 public function has($entryIdentifier) {
149 $statementHandle = $this->databaseHandle->prepare(
'SELECT COUNT("identifier") FROM "cache" WHERE "identifier"=? AND "context"=? AND "cache"=?' . $this->
getNotExpiredStatement());
150 $statementHandle->execute(array($entryIdentifier, $this->context, $this->cacheIdentifier));
151 return $statementHandle->fetchColumn() > 0;
163 public function remove($entryIdentifier) {
164 $statementHandle = $this->databaseHandle->prepare(
'DELETE FROM "tags" WHERE "identifier"=? AND "context"=? AND "cache"=?');
165 $statementHandle->execute(array($entryIdentifier, $this->context, $this->cacheIdentifier));
166 $statementHandle = $this->databaseHandle->prepare(
'DELETE FROM "cache" WHERE "identifier"=? AND "context"=? AND "cache"=?');
167 $statementHandle->execute(array($entryIdentifier, $this->context, $this->cacheIdentifier));
168 return $statementHandle->rowCount() > 0;
178 $statementHandle = $this->databaseHandle->prepare(
'DELETE FROM "tags" WHERE "context"=? AND "cache"=?');
179 $statementHandle->execute(array($this->context, $this->cacheIdentifier));
180 $statementHandle = $this->databaseHandle->prepare(
'DELETE FROM "cache" WHERE "context"=? AND "cache"=?');
181 $statementHandle->execute(array($this->context, $this->cacheIdentifier));
192 $statementHandle = $this->databaseHandle->prepare(
'DELETE FROM "cache" WHERE "context"=? AND "cache"=? AND "identifier" IN (SELECT "identifier" FROM "tags" WHERE "context"=? AND "cache"=? AND "tag"=?)');
193 $statementHandle->execute(array($this->context, $this->cacheIdentifier, $this->context, $this->cacheIdentifier, $tag));
194 $statementHandle = $this->databaseHandle->prepare(
'DELETE FROM "tags" WHERE "context"=? AND "cache"=? AND "tag"=?');
195 $statementHandle->execute(array($this->context, $this->cacheIdentifier, $tag));
207 $statementHandle = $this->databaseHandle->prepare(
'SELECT "identifier" FROM "tags" WHERE "context"=? AND "cache"=? AND "tag"=?');
208 $statementHandle->execute(array($this->context, $this->cacheIdentifier, $tag));
209 return $statementHandle->fetchAll(\PDO::FETCH_COLUMN);
219 $statementHandle = $this->databaseHandle->prepare(
'DELETE FROM "tags" WHERE "context"=? AND "cache"=? AND "identifier" IN ' .
'(SELECT "identifier" FROM "cache" WHERE "context"=? AND "cache"=? AND "lifetime" > 0 AND "created" + "lifetime" < ' .
$GLOBALS[
'EXEC_TIME'] .
')');
220 $statementHandle->execute(array($this->context, $this->cacheIdentifier, $this->context, $this->cacheIdentifier));
221 $statementHandle = $this->databaseHandle->prepare(
'DELETE FROM "cache" WHERE "context"=? AND "cache"=? AND "lifetime" > 0 AND "created" + "lifetime" < ' .
$GLOBALS[
'EXEC_TIME']);
222 $statementHandle->execute(array($this->context, $this->cacheIdentifier));
231 return ' AND ("lifetime" = 0 OR "created" + "lifetime" >= ' .
$GLOBALS[
'EXEC_TIME'] .
')';
242 $splitdsn = explode(
':', $this->dataSourceName, 2);
243 $this->pdoDriver = $splitdsn[0];
244 if ($this->pdoDriver ===
'sqlite' && !file_exists($splitdsn[1])) {
250 $this->databaseHandle->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
251 if (substr($this->pdoDriver, 0, 5) ===
'mysql') {
252 $this->databaseHandle->exec(
'SET SESSION sql_mode=\'ANSI\';');
254 }
catch (\PDOException $e) {
255 throw new \RuntimeException(
'Could not connect to cache table with DSN "' . $this->dataSourceName .
'". PDO error: ' . $e->getMessage(), 1334736164);
268 $this->databaseHandle,
270 \
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'core') .
271 'Resources/Private/Sql/Cache/Backend/PdoBackendCacheAndTags.sql' 273 }
catch (\PDOException $e) {
274 throw new \RuntimeException(
'Could not create cache tables with DSN "' . $this->dataSourceName .
'". PDO error: ' . $e->getMessage(), 1259576985);
findIdentifiersByTag($tag)
static importSql(\PDO $databaseHandle, $pdoDriver, $pathAndFilename)
static makeInstance($className)
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.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]