Pimcore\Cache::write PHP Method

write() public static method

Write the stack to the cache
public static write ( ) : void
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 = [];
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * this method is called with register_shutdown_function() and writes all data queued into the cache
  * @static
  * @return void
  */
 public static function shutdown()
 {
     // set inShutdown to true so that the output-buffer knows that he is allowed to send the headers
     self::$inShutdown = true;
     // flush all custom output buffers
     while (@ob_end_flush()) {
     }
     // flush everything
     flush();
     if (function_exists("fastcgi_finish_request")) {
         fastcgi_finish_request();
     }
     // clear tags scheduled for the shutdown
     Cache::clearTagsOnShutdown();
     // write collected items to cache backend and remove the write lock
     Cache::write();
     Cache::removeWriteLock();
     // release all open locks from this process
     Model\Tool\Lock::releaseAll();
     // disable logging - otherwise this will cause problems in the ongoing shutdown process (session write, __destruct(), ...)
     \Logger::resetLoggers();
 }