More fixes on cache to reduce queries
authorRoland Häder <roland@mxchange.org>
Sun, 31 Aug 2008 09:45:28 +0000 (09:45 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 31 Aug 2008 09:45:28 +0000 (09:45 +0000)
inc/libs/rallye_functions.php
inc/load_cache.php

index e67677e419cd6082706fbbc28e779f21cbe559a2..69dc4de3b288695f2e0a66bfd9bb99475a801c42 100644 (file)
@@ -770,22 +770,22 @@ function RALLYE_TEMPLATE_SELECTION($name="template", $default="")
 //
 function RALLYE_GET_REFCOUNT($uid, $old=0)
 {
-       global $REF_SYSTEM, $REF_DEPTHS, $_CONFIG;
+       global $_CONFIG;
        // Check current refs
        if (GET_EXT_VERSION("cache") >= "0.1.2")
        {
                // Get refs from cache
                $cnt = 0;
-               foreach ($REF_SYSTEM['userid'] as $id=>$u_id)
+               foreach ($cacheArray['ref_system']['userid'] as $id=>$u_id)
                {
-                       if (($u_id == $uid) && ($REF_SYSTEM['level'][$id] == 0))
+                       if (($u_id == $uid) && ($cacheArray['ref_system']['level'][$id] == 0))
                        {
-                               foreach ($REF_DEPTHS['level'] as $level)
+                               foreach ($cacheArray['ref_depths']['level'] as $level)
                                {
-                                       if (($level == $REF_SYSTEM['level'][$id]) && ($level == 0))
+                                       if (($level == $cacheArray['ref_system']['level'][$id]) && ($level == 0))
                                        {
                                                // Level does exist so abort here
-                                               $cnt = $REF_SYSTEM['counter'][$id];
+                                               $cnt = $cacheArray['ref_system']['counter'][$id];
                                                //* DEBUG: */ echo "*".$uid."/".$cnt."*<br />";
                                                break;
                                        }
@@ -800,7 +800,7 @@ function RALLYE_GET_REFCOUNT($uid, $old=0)
                        }
                }
                //* DEBUG: */ echo "<PRE>";
-               //* DEBUG: */ print_r($REF_SYSTEM);
+               //* DEBUG: */ print_r($cacheArray['ref_system']);
                //* DEBUG: */ echo "</PRE>";
                //* DEBUG: */ die();
 
index 2804679016b15f967fa4360806644d07318be2cc..cdad73540e39b1d1301eba61d418dee402cbe77a 100644 (file)
@@ -208,6 +208,16 @@ if ($cacheInstance->cache_file("config", true) == true) {
 
        // Overwrite the config with the cache version
        $cacheArray['config'] = $newCache;
+
+       // When there is a period (.) in the result this test will fail and so the cache file is
+       // damaged/corrupted
+       $TEST = "failed";
+       if (count($cacheArray['config']) > 0 ) $TEST = ($CNT / (count($cacheArray['config'])));
+       if ($TEST != bigintval($TEST)) {
+               // Cache file is corrupted!
+               $cacheInstance->cache_destroy();
+               unset($cacheArray['config']);
+       }
 } elseif (($_CONFIG['cache_config'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
        // Create cache file here
        $cacheInstance->cache_init("CONFIG");
@@ -229,27 +239,27 @@ $cacheInstance->cache_close();
 // Next cached table is the referral system (refsystem)...
 if ($cacheInstance->cache_file("refsystem", true) == true) {
        // Load referral system from cache
-       global $REF_SYSTEM;
-       $REF_SYSTEM = $cacheInstance->cache_load();
+       global $cacheArray;
+       $cacheArray['ref_system'] = $cacheInstance->cache_load();
 
        // Valid cache file
        $CNT = 0;
-       foreach ($REF_SYSTEM as $k=>$array) {
+       foreach ($cacheArray['ref_system'] as $k=>$array) {
                $CNT += count($array);
        }
 
        // When there is a period (.) in the result this test will fail and so the cache file is
        // damaged/corrupted
        $TEST = "failed";
-       if (count($REF_SYSTEM) > 0 ) $TEST = ($CNT / (count($REF_SYSTEM)));
+       if (count($cacheArray['ref_system']) > 0 ) $TEST = ($CNT / (count($cacheArray['ref_system'])));
        if ($TEST != bigintval($TEST)) {
                // Cache file is corrupted!
                $cacheInstance->cache_destroy();
-               unset($REF_SYSTEM);
+               unset($cacheArray['ref_system']);
        }
 } elseif (($_CONFIG['cache_refsys'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
        // Create cache file here
-       $cacheInstance->cache_init("REFSYSTEM");
+       $cacheInstance->cache_init("refsystem");
 
        // Load all modules and their data
        $result = SQL_QUERY("SELECT id, userid, level, counter FROM "._MYSQL_PREFIX."_refsystem ORDER BY userid, level", __FILE__, __LINE__);
@@ -268,23 +278,23 @@ $cacheInstance->cache_close();
 // Next cached table is the referral system (refdepths)...
 if ($cacheInstance->cache_file("refdepths", true) == true) {
        // Load referral system from cache
-       global $REF_DEPTHS;
-       $REF_DEPTHS = $cacheInstance->cache_load();
+       global $cacheArray;
+       $cacheArray['ref_depths'] = $cacheInstance->cache_load();
 
        // Valid cache file
        $CNT = 0;
-       foreach ($REF_DEPTHS as $k=>$array) {
+       foreach ($cacheArray['ref_depths'] as $k=>$array) {
                $CNT += count($array);
        }
 
        // When there is a period (.) in the result this test will fail and so the cache file is
        // damaged/corrupted
        $TEST = "failed";
-       if (count($REF_DEPTHS) > 0 ) $TEST = ($CNT / (count($REF_DEPTHS)));
+       if (count($cacheArray['ref_depths']) > 0 ) $TEST = ($CNT / (count($cacheArray['ref_depths'])));
        if ($TEST != bigintval($TEST)) {
                // Cache file is corrupted!
                $cacheInstance->cache_destroy();
-               unset($REF_DEPTHS);
+               unset($cacheArray['ref_depths']);
        }
 } elseif (($_CONFIG['cache_refdepth'] == "Y") && ($CSS != "1") && ($CSS != "-1")) {
        // Create cache file here