Saves in cache the rendered cache data.

@param \BackBee\Event\Event $event
438289
public function onPostRenderContent(RendererEvent $event)
    {
        // Checks if content caching is available
        $this->object = $event->getTarget();
        if (false === ($this->object instanceof AbstractClassContent) || false === $this->checkCacheContentEvent()) {
            return;
        }

        $renderer = $event->getRenderer();
        // Checks if cache_id is available
        if (false === $cache_id = $this->getContentCacheId($renderer)) {
            return;
        }

        // Gets the lifetime to set
        if (null === $lifetime = $this->object->getProperty('cache-lifetime')) {
            $lifetime = 0;
        }

        // Computes $lifetime according param and children
        $uids = $this->application->getEntityManager()->getRepository(ClassUtils::getRealClass($this->object))
            ->getUnorderedChildrenUids($this->object)
        ;

        $lifetime = $this->cache_content->getMinExpireByTag($uids, $lifetime);

        $render = $event->getRender();
        $this->cache_content->save($cache_id, $render, $lifetime, $this->object->getUid());
        $this->application->debug(sprintf(
            'Save cache (id: %s, lifetime: %d) for rendering `%s(%s)` with mode `%s`.',
            $cache_id,
            $lifetime,
            get_class($this->object),
            $this->object->getUid(),
            $renderer->getMode()
        ));
    }
694285
public function afterSave(Event $Event) {
		if ($this->_checkEvent($Event)) {
			$table = $Event->getSubject();
			$record = $Event->getData('record');
			$Storage = StorageManager::adapter($record->adapter);
			try {
				$id = $record->{$table->primaryKey()};
				$filename = $this->stripDashes($id);
				$file = $record['file'];
				$record['path'] = $this->fsPath('images' . DS . $record['model'], $id);
				if ($this->_config['preserveFilename'] === true) {
					$path = $record['path'] . $record['filename'];
				} else {
					$path = $record['path'] . $filename . '.' . $record['extension'];
				}

				if ($this->adapterClass === 'AmazonS3' || $this->adapterClass === 'AwsS3') {
					$path = str_replace('\\', '/', $path);
					$record['path'] = str_replace('\\', '/', $record['path']);
				}

				$Storage->write($path, file_get_contents($file['tmp_name']), true);

				$data = $table->save($record, [
					'validate' => false,
					'callbacks' => false
				]);

				$operations = Configure::read('FileStorage.imageSizes.' . $record['model']);
				if (!empty($operations)) {
					$this->_createVersions($table, $record, $operations);
				}
				$table->data = $data;
			} catch (\Exception $e) {
				$this->log($e->getMessage());
			}
		}
	}
1066521
public function doSerialize(EventInterface $event)/*# : bool */
    {
        /* @var CacheItem $item */
        $item = $event->getParam('item');
        $item->setStrVal(serialize($item->get()));
        return true;
    }
52160
public static function onFlushContent(Event $event)
    {
        $content = $event->getTarget();
        if (!($content instanceof AbstractClassContent)) {
            return;
        }

        $application = $event->getApplication();
        $em = $application->getEntityManager();
        $uow = $em->getUnitOfWork();
        if ($uow->isScheduledForDelete($content)) {
            return;
        }

        if (null !== $page = $content->getMainNode()) {
            if (null !== $page->getMetaData()) {
                $newEvent = new Event($page, $content);
                $newEvent->setDispatcher($event->getDispatcher());
                self::onFlushPage($newEvent);
            }
        }
    }
98835
public function recordCacheHit(CacheHit $event)
    {
        if (! Telescope::isRecording() || $this->shouldIgnore($event)) {
            return;
        }

        Telescope::recordCache(IncomingEntry::make([
            'type' => 'hit',
            'key' => $event->key,
            'value' => $event->value,
        ]));
    }
989884
public static function clearCache(Event $event)
    {
        $options = self::getOptions($event);
        $binDir = $options['symfony-bin-dir'];

        $opcode = '';
        if (array_key_exists('accelerator-cache-opcode', $options)) {
            $opcode .= ' --opcode';
        }

        $user = '';
        if (array_key_exists('accelerator-cache-user', $options)) {
            $user .= ' --user';
        }

        $cli = '';
        if (array_key_exists('accelerator-cache-cli', $options)) {
            $cli .= ' --cli';
        }

        $auth = '';
        if (array_key_exists('accelerator-cache-auth', $options)) {
            $auth .= ' --auth '.escapeshellarg($options['accelerator-cache-auth']);
        }

        try {
            static::executeCommand($event, $binDir, 'cache:accelerator:clear'.$opcode.$user.$cli.$auth, $options['process-timeout']);
        } catch (\RuntimeException $e) {
            $event->getIO()->write('<error>'.$e->getMessage().'</error>');
        }
    }
534772
public function onInitCache($event)
    {
        $sender = $event->sender;
        $data = $event->data;
        if (isset($data['prefix'])) {
            $sender->cachePrefix = $data['prefix'];
        } else {
            $sender->cachePrefix = $sender::className();
        }
    }
587228
public function saveEvent($eventData)
    {
        $serializedEvent = $this->jsonSerializer->serialize($eventData);
        $insertData = ['event_id' => md5($serializedEvent . time()), 'data' => $serializedEvent];
        $this->getConnection()->insertOnDuplicate($this->getMainTable(), $insertData, ['data']);
    }
1292842
public function handleEventScriptEvent($event)
    {
        \Cache::forget(Cache::EVENT_SCRIPT_CACHE_PREFIX . $event->script->name);

        return true;
    }
177832
public function trigger(Event $event) {
    $request = $event->getTarget();
    
    $cachedRequest = new CachedRequest($request->getURL());
    $cachedRequest->setCachedResponse($event->getData()->response);
    $cachedRequest->setHeaders($event->getData()->headers);
    
    $this->addCachedRequest($cachedRequest);
  }
398468
public function beforeSave(Save $event)
    {
        $entity = $event->getTarget();
        $property = $this->getPropertyName();
        $field = $this->getForeignKey();
        $data = $event->data;
        if (isset($entity->$property) && !is_null($entity->$property)) {
            /** @var Entity $object */
            $object = $entity->$property;
            $data[$field] = $object;
            $class = $this->getRelatedEntity();
            if ($object instanceof $class) {
                $pmk = $object->getPrimaryKey();
                $data[$field] = $object->$pmk;
            }
            $event->data = $data;
        }
    }
412138
public function sendEvent(Event $event)
    {
        try {
            $this->eventFactory->addDefaultTagsToEntity($event);
            $this->sendEventThroughSenders($event);
        } catch (\Exception $exception) {
            $this->logException($exception);
        }
    }
438752
public function onCreateZone(ZoneEvent $event)
    {
        $zone = $event->getZone();
        if ($zone->getComponents()->isEmpty()) {
            return;
        }

        $this->save($zone);
    }
264187
protected function store($label, CacheEvent $event)
    {
        $tags = $event->tags;

        $this->events[$label]['keys'][] = ! empty($tags)
            ? ['tags' => $tags, 'key' => $event->key]
            : $event->key;

        $this->events[$label]['total']++;
    }
651099
public function save(EventInterface $event) {
        $request = $event->getRequest();
        $database = $event->getDatabase();

        $user = $request->getUser();
        $imageIdentifier = $request->getImage()->getImageIdentifier();

        try {
            $database->updateMetadata(
                $user,
                $imageIdentifier,
                $this->properties
            );
        } catch (DatabaseException $e) {
            $database->deleteImage($user, $imageIdentifier);

            throw new RuntimeException('Could not store EXIF-metadata', 500);
        }
    }
1283784
protected function eventWasProcessed($event)
    {
        if ($this->eventExpired($event)) {
            return true;
        }

        $this->resetEventCache($event);

        return false;
    }
194073
public static function onFlushContent(Event $event)
    {
        $content = $event->getTarget();
        $application = $event->getApplication();

        $token = $application->getSecurityContext()->getToken();
        if (!($token instanceof BBUserToken)) {
            return;
        }

        $em = $application->getEntityManager();
        $uow = $em->getUnitOfWork();

        if ($uow->isScheduledForInsert($content) && AbstractClassContent::STATE_NEW === $content->getState()) {
            if (null === $draft = $content->getDraft()) {
                $draft = $em->getRepository('BackBee\ClassContent\Revision')->checkout($content, $token);
            }

            $content->setDraft($draft);
            $em->persist($draft);
            $uow->computeChangeSet($em->getClassMetadata('BackBee\ClassContent\Revision'), $draft);
        } elseif ($uow->isScheduledForDelete($content)) {
            $revisions = $em->getRepository('BackBee\ClassContent\Revision')->getRevisions($content);
            foreach ($revisions as $revision) {
                $revision->setContent(null);
                $revision->setState(Revision::STATE_DELETED);
                $uow->computeChangeSet($em->getClassMetadata('BackBee\ClassContent\Revision'), $revision);
            }
        }
    }