]> git.mxchange.org Git - core.git/commitdiff
Prevent generating cache keys if no query caching is enabled.
authorRoland Haeder <roland@mxchange.org>
Thu, 25 Dec 2014 11:41:39 +0000 (12:41 +0100)
committerRoland Haeder <roland@mxchange.org>
Thu, 25 Dec 2014 11:41:39 +0000 (12:41 +0100)
Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/main/database/class_BaseDatabaseWrapper.php
inc/classes/main/database/databases/class_LocalFileDatabase.php

index cd785bb7ca341fca74e297b9a712df52f902aaab..3155f823326d14f87d064e7298140233dff87c1c 100644 (file)
@@ -82,12 +82,18 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
         * @return      void
         */
        protected function queryInsertDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) {
-               // First get a key suitable for our cache and extend it with this class name
-               $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
-               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+               // Default cache key is NULL
+               $cacheKey = NULL;
+
+               // Is cache enabled?
+               if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) {
+                       // First get a key suitable for our cache and extend it with this class name
+                       $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
+                       //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+               } // END - if
 
                // Does this key exists in cache?
-               if ($this->cacheInstance->offsetExists($cacheKey)) {
+               if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey))) {
                        // Purge the cache
                        $this->cacheInstance->purgeOffset($cacheKey);
                } // END - if
@@ -104,12 +110,18 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
         * @return      void
         */
        protected function queryUpdateDataSet (StoreableCriteria $dataSetInstance, array $onlyKeys = array()) {
-               // First get a key suitable for our cache and extend it with this class name
-               $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
-               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+               // Init cache key
+               $cacheKey = NULL;
+
+               // Is cache enabled?
+               if ($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) {
+                       // First get a key suitable for our cache and extend it with this class name
+                       $cacheKey = $this->getCacheKeyByCriteria($dataSetInstance, $onlyKeys);
+                       //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Using cache key ' . $cacheKey . ' for purging ...');
+               } // END - if
 
                // Does this key exists in cache?
-               if ($this->cacheInstance->offsetExists($cacheKey)) {
+               if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey))) {
                        // Purge the cache
                        $this->cacheInstance->purgeOffset($cacheKey);
                } // END - if
index aaa524c8a554064542b6ddf77212185b2848f88e..7f23e2adb07c17d1a4f302a2f9d8367209f522e8 100644 (file)
@@ -536,12 +536,14 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
                                        } // END - foreach
 
                                        // Is all found?
+                                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: isFound=' . intval($isFound));
                                        if ($isFound === TRUE) {
                                                // Shall we skip this entry?
                                                if ($searchInstance->getSkip() > 0) {
                                                        // We shall skip some entries
                                                        if ($skipFound < $searchInstance->getSkip()) {
                                                                // Skip this entry
+                                                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Found entry, but skipping ...');
                                                                $skipFound++;
                                                                break;
                                                        } // END - if
@@ -559,6 +561,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
                                                } // END - foreach
 
                                                // Write the data to a local file
+                                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing dataArray()=' . count($dataArray) . ' to ' . $dataFile . ' ...');
                                                $this->writeDataArrayToFqfn($pathName . $dataFile, $dataArray);
 
                                                // Count found entries up