Beispiel #1
0
 /**
  * Write the stack to the cache
  *
  * @return void
  */
 public static function write()
 {
     if (self::hasWriteLock()) {
         return;
     }
     $processedKeys = array();
     $count = 0;
     foreach (self::$saveStack as $conf) {
         if (in_array($conf[1], $processedKeys)) {
             continue;
         }
         try {
             forward_static_call_array(array(__CLASS__, "storeToCache"), $conf);
         } catch (\Exception $e) {
             \Logger::error("Unable to put element " . $conf[1] . " to cache because of the following reason: ");
             \Logger::error($e);
         }
         $processedKeys[] = $conf[1];
         // index 1 is the key for the cache item
         // only add $maxWriteToCacheItems items att once to the cache for performance issues
         $count++;
         if ($count > self::$maxWriteToCacheItems) {
             break;
         }
     }
     // reset
     self::$saveStack = array();
 }
Beispiel #2
0
 /**
  * Write the stack to the cache
  *
  * @return void
  */
 public static function write()
 {
     if (self::hasWriteLock()) {
         return;
     }
     $processedKeys = [];
     foreach (self::$saveStack as $conf) {
         if (in_array($conf[1], $processedKeys)) {
             continue;
         }
         try {
             forward_static_call_array([__CLASS__, "storeToCache"], $conf);
         } catch (\Exception $e) {
             Logger::error("Unable to put element " . $conf[1] . " to cache because of the following reason: ");
             Logger::error($e);
         }
         $processedKeys[] = $conf[1];
         // index 1 is the key for the cache item
     }
     // reset
     self::$saveStack = [];
 }