Persists a cache item immediately.

@param CacheItemInterface $item The cache item to save

@return bool
@throws CacheKeyException
196173
public function save(CacheItemInterface $item)
    {
        $key = $item->getKey();

        $this->validateKey($key);

        $this->data[$key] = $item;

        return true;
    }
1090652
protected static function setCache($id = null, $item = null)
    {
        static::getCacheInstance()->set(static::getCacheId($id), $item);

        return $item;
    }
1001074
public function saveData($item)
    {
        $attributes = $item->dataProperties->getAttributesForSave($item->id);
        if(empty($attributes)) return false;

        $classData = static::getClassData();

        foreach ($attributes as $slug => $values)
        {

            $classData::deleteAll(['item_id' => $item->id, 'property_slug' => $slug]);
            $values = (is_array($values)) ? $values : [$values];

            foreach ($values as $value){

                $value = (is_array($value)) ? array_values($value)[0] : $value;

                $data = new $classData;
                $data->value = $value;
                $data->property_slug = $slug;
                $data->item_id = $item->id;
                if(!empty($value)) $data->save();
            }
        }
    }
1156599
public function set(CacheableInterface $item)
    {
        $this->connection->set($item->getHashKey(), $item->getDataForCache(), $item->getTtl());
    }
847807
private function getFreshDataWithCache(QueueItem $item)
    {
        $sdk = $this->getSdk($item);
        $entity = $sdk->get($item->getId())->wait(true);
        if (false === $this->shouldCacheEntity($item->getType(), $item->getId())) {
            return $entity;
        }
        if ($entity) {
            $this->logger->debug('Saving to cache', [
                'type' => $item->getType(),
                'id' => $item->getId(),
            ]);
            $this->cache->save(
                $this->getKeyFromQueueItem($item),
                $this->serializer->serialize($entity, 'json', ['type' => true]),
                $this->lifetime
            );
        } else {
            $this->logger->debug('404 from SDK', [
                'type' => $item->getType(),
                'id' => $item->getId(),
            ]);
        }

        return $entity;
    }
145117
protected function createResponseFromCacheItem(CacheItemInterface $cacheItem)
    {
        $data = $cacheItem->get();

        $response = $data['response'];
        $stream = $this->streamFactory->createStream($data['body']);

        try {
            $stream->rewind();
        } catch (Exception $e) {
            throw new RewindStreamException('Cannot rewind stream.', 0, $e);
        }

        $response = $response->withBody($stream);

        return $response;
    }
261415
private function saveInCache(string $class, ClassMetadataInterface $classMetadata): void
    {
        if (null === $this->cache) {
            return;
        }

        if ($this->cache instanceof Cache) {
            $this->cache->save($class, $classMetadata);
        } else {
            $class = preg_replace('#[\{\}\(\)/\\\\@:]#', '_', str_replace('_', '__', $class));
            $item = $this->cache->getItem($class);
            $item->set($classMetadata);

            $this->cache->save($item);
        }
    }
717988
public function saveItem($entity)
    {
        $this->em->persist($entity);
        $this->em->flush();
        return $entity;
    }
892053
public function save(CacheItemInterface $item)
    {
        $metadata = $item->getMetadata();
        $metadata[ 'data' ] = $item->get();

        return wincache_ucache_set($this->prefixKey . $item->getKey(), $metadata, $metadata[ 'ttl' ]);
    }
159206
private function saveIntoCache($key, MessageInterface $message)
    {
        if ($this->cache) {
            $item = $this->cache->getItem($key);

            $item->set([
                $message->getHeaders(),
                (string) $message->getBody(),
            ]);

            $this->cache->save($item);
        }
    }
183897
public function save(CacheItemInterface $item)
    {
        $this->cache->set($item->getKey(), $item);
        return $this->commit();
    }
111577
public function get(CacheableInterface $item)
    {
        $targetFile = $this->getTargetFile($item->getHashKey());

        $return = false;
        if (file_exists($targetFile)) {
            if ($item->getTtl() > 0 && ((filemtime($targetFile) + $item->getTtl()) < time())) {
                $this->remove($item);
            } else {
                $return = unserialize(file_get_contents($targetFile, false, null, strlen(self::STR_PREFIX)));
            }
        }

        return $return;
    }
191989
public function get(CacheableInterface $item)
    {
        if (false !== $result = parent::get($item)) {
            return $result;
        }

        return $this->adapter->get($item);
    }
1303620
public function savePersistCurrentCookie($item)
    {
        $varName = $this->getCurrentVarName();
        CookieJar::instance()->newCookie()
            ->setName($varName)
            ->setValue($item->id)
            ->save();
    }
44611
protected function setActive(ItemInterface $item = null)
    {
        if ($item) {
            $this->setActive($item->getParent());
            $item->setAttribute('class', $item->getAttribute('class', '') . ' active');
        }
    }
1329728
protected function createItem(/*# string */ $key)/*# : CacheItemInterface */
    {
        // validate key first
        $this->validateKey($key);

        // use item factory
        if (is_callable($this->item_factory)) {
            $func = $this->item_factory;
            $item = $func($key, $this, $this->item_config);

        // default CacheItem class
        } else {
            $item = new CacheItem($key, $this, $this->item_config);
        }

        return $item;
    }
1245747
public function save($key, $item, $ttl = null)
    {
        try {
            $this->handler->set($key, $item, $ttl);
        } catch (\Exception $e) {
            return $e->getMessage();
        }
        return true;
    }