Fixed bug #15196: [caching framework] Speedup t3lib_cache_backend_DbBackend::has...
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 26 Jul 2010 22:55:46 +0000 (22:55 +0000)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 26 Jul 2010 22:55:46 +0000 (22:55 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8278 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/cache/backend/class.t3lib_cache_backend_dbbackend.php

index e372607..a32dd4a 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2010-07-27  Christian Kuhn  <lolli@schwarzbu.ch>
 
+       * Fixed bug #15196: [caching framework] Speedup t3lib_cache_backend_DbBackend::has($entryIdentifier) (Thanks to Michael Knabe)
        * Fixed bug #13060: t3lib_htmlmail: Deprecated message with PHP 5.3 for sql_regcase (Thanks to Martin Müller)
 
 2010-07-26  Steffen Kamper  <steffen@typo3.org>
index 15ab191..4858ead 100644 (file)
@@ -174,22 +174,21 @@ class t3lib_cache_backend_DbBackend extends t3lib_cache_backend_AbstractBackend
        /**
         * Checks if a cache entry with the specified identifier exists.
         *
-        * @param unknown_type
+        * @param string Specifies the identifier to check for existence
         * @return boolean TRUE if such an entry exists, FALSE if not
         * @author Ingo Renner <ingo@typo3.org>
         */
        public function has($entryIdentifier) {
-               $hasEntry = false;
+               $hasEntry = FALSE;
 
-               $cacheEntries = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                       'content',
+               $cacheEntries = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       '*',
                        $this->cacheTable,
-                       'identifier = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($entryIdentifier, $this->cacheTable) . ' '
-                               . 'AND crdate + lifetime >= ' . $GLOBALS['EXEC_TIME']
+                       'identifier = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($entryIdentifier, $this->cacheTable) .
+                               AND crdate + lifetime >= ' . $GLOBALS['EXEC_TIME']
                );
-
-               if (count($cacheEntries) == 1) {
-                       $hasEntry = true;
+               if ($cacheEntries >= 1) {
+                       $hasEntry = TRUE;
                }
 
                return $hasEntry;