Prevent generating cache keys if no query caching is enabled.
[core.git] / inc / classes / main / database / class_BaseDatabaseWrapper.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