public function save(ProjectDescriptor $projectDescriptor): void
    {
        $keys = [];
        $cache = $this->getCache();

        foreach ($cache as $key) {
            $keys[] = $key;
        }

        // store the settings for this Project Descriptor
        $cache->setItem(self::KEY_SETTINGS, $projectDescriptor->getSettings());

        // store cache items
        $usedKeys = [self::KEY_SETTINGS];
        foreach ($projectDescriptor->getFiles() as $file) {
            $key = self::FILE_PREFIX . md5($file->getPath());
            $usedKeys[] = $key;
            $cache->setItem($key, $file);
        }

        // remove any keys that are no longer used.
        $invalidatedKeys = array_diff($keys, $usedKeys);
        if ($invalidatedKeys) {
            $cache->removeItems($invalidatedKeys);
        }

        if ($cache instanceof OptimizableInterface) {
            $cache->optimize();
        }
    }
public function save(ProjectDescriptor $projectDescriptor): void
    {
        $keys = [];
        $cache = $this->getCache();

        foreach ($cache as $key) {
            $keys[] = $key;
        }

        // store the settings for this Project Descriptor
        $cache->setItem(self::KEY_SETTINGS, $projectDescriptor->getSettings());

        // store cache items
        $usedKeys = [self::KEY_SETTINGS];
        foreach ($projectDescriptor->getFiles() as $file) {
            $key = self::FILE_PREFIX . md5($file->getPath());
            $usedKeys[] = $key;
            $cache->setItem($key, $file);
        }

        // remove any keys that are no longer used.
        $invalidatedKeys = array_diff($keys, $usedKeys);
        if ($invalidatedKeys) {
            $cache->removeItems($invalidatedKeys);
        }

        if ($cache instanceof OptimizableInterface) {
            $cache->optimize();
        }
    }
public function save ( ProjectDescriptor $ projectDescriptor ) : void { $ keys = [ ] ; $ cache = $ this -> getCache ( ) ; foreach ( $ cache as $ key ) { $ keys [ ] = $ key ; } // store the settings for this Project Descriptor $ cache -> setItem ( self :: KEY_SETTINGS , $ projectDescriptor -> getSettings ( ) ) ; // store cache items $ usedKeys = [ self :: KEY_SETTINGS ] ; foreach ( $ projectDescriptor -> getFiles ( ) as $ file ) { $ key = self :: FILE_PREFIX . md5 ( $ file -> getPath ( ) ) ; $ usedKeys [ ] = $ key ; $ cache -> setItem ( $ key , $ file ) ; } // remove any keys that are no longer used. $ invalidatedKeys = array_diff ( $ keys , $ usedKeys ) ; if ( $ invalidatedKeys ) { $ cache -> removeItems ( $ invalidatedKeys ) ; } if ( $ cache instanceof OptimizableInterface ) { $ cache -> optimize ( ) ; } }
Stores a Project Descriptor in the Cache.
Stores a Project Descriptor in the Cache .