Set a metadatas record

@param  string $id        Cache id
@param  array  $metadatas Associative array of metadatas
@param  boolean $save     optional pass false to disable saving to file
@return boolean True if no problem
485058
protected function _setMetadatas($id, $metadatas, $save = true)
    {
        if (count($this->_metadatasArray) >= $this->_options['metadatas_array_max_size']) {
            $n = (int) ($this->_options['metadatas_array_max_size'] / 10);
            $this->_metadatasArray = array_slice($this->_metadatasArray, $n);
        }
        if ($save) {
            $result = $this->_saveMetadatas($id, $metadatas);
            if (!$result) {
                return false;
            }
        }
        $this->_metadatasArray[$id] = $metadatas;
        return true;
    }
1086556
private function removeFromMetaData($id) {
        $storageFileName = $this->directory . $id . '.info';
        if (file_exists($storageFileName) && is_writable($storageFileName)) {
            unset($storageFileName);
            return true;
        }
        return false;
    }
140100
private function dumpMetadata(array $metadata, InputInterface $input, OutputInterface $output)
    {
        foreach ($metadata as $name => $meta) {
            $output->writeln(sprintf('<info>%s</info>', $name));

            foreach ($meta['fields'] as $fieldName => $columnName) {
                $output->writeln(sprintf('  <comment>></comment> %s <info>=></info> %s', $fieldName, $columnName));
            }
        }
        $output->writeln('---------------');
        $output->writeln('----  END  ----');
        $output->writeln('---------------');
        $output->writeln('');

        if ($input->getOption('filename')) {
            $directory = \dirname($input->getOption('filename'));
            $filename = basename($input->getOption('filename'));

            if (empty($directory) || '.' === $directory) {
                $directory = getcwd();
            }

            $adapter = new LocalAdapter($directory, true);
            $fileSystem = new Filesystem($adapter);
            $success = $fileSystem->write($filename, json_encode($metadata), true);

            if ($success) {
                $output->writeLn(sprintf('<info>File %s/%s successfully created</info>', $directory, $filename));
            } else {
                $output->writeLn(sprintf('<error>File %s/%s could not be created</error>', $directory, $filename));
            }
        }
    }
602424
public function update(array $metadata, $saveMode=false)
    {
        $fromSchema = $this->schemaManager->createSchema();
        $toSchema = $this->getSchemaFromMetadata($metadata);

        $comparator = new Comparator;
        $schemaDiff = $comparator->compare($fromSchema, $toSchema);

        if ($saveMode) {
            $statements = $schemaDiff->toSaveSql($this->platform);
        } else {
            $statements = $schemaDiff->toSql($this->platform);
        }

        $this->build($statements);

        return $statements;
    }
1228550
public function ___expire($id)
    {
        $metadatas = $this->_getMetadatas($id);
        if ($metadatas) {
            $metadatas['expire'] = 1;
            $this->_setMetadatas($id, $metadatas);
        }
    }
731121
public function propagateIdToSources($save = true)
    {
        foreach ($this->translations as $source)
        {
            $source->setExtensionNodeId($this->getKey(), $save);
        }
    }
402985
public function recordCacheSave($model, $id, $value) {
        $cache_key = "record_" . $model . $id;
        Cache::set($cache_key, $value);
    }
58426
public function saveMeta($id = null) {

        $id = (isset($this->request->data['id'])) ? $this->request->data['id'] : $id;
        $this->CmsContentMeta = TableRegistry::get('CmsContentMeta');
        $meta = $this->CmsContentMeta->get($id);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $this->CmsContentMeta->patchEntity($meta, $this->request->data);
            if ($this->CmsContentMeta->save($meta)) {
                $this->Flash->success('The meta has been saved.');
                exit('ok');
            } else {
                $this->Flash->error('The meta could not be saved. Please, try again.');
                exit('ko');
            }
        }
    }
1014777
public function update_meta( $meta_key, $meta_value ) {
		$updated = update_metadata( $this->meta_type, $this->get_id(), $meta_key, $meta_value );

		if ( false !== $updated ) {
			$this->metadata[ $meta_key ] = $meta_value;

			if ( $attribute = $this->get_mapping_attribute( $meta_key ) ) {
				$this->set_attribute( $attribute, $meta_value );
			}

			return true;
		}

		return false;
	}
329136
public function generate(array $metadatas, $outputDirectory)
    {
        foreach ($metadatas as $metadata) {
            $this->writeEntityClass($metadata, $outputDirectory);
        }
    }
1373098
private function doPutMetadata(EntityMetadata $metadata)
    {
        if (true === $this->hasCache()) {
            $this->cache->putMetadataInCache($metadata);
        }
        $this->setToMemory($metadata);
        return $this;
    }
860115
public function addMetadata(Metadata $metadata)
    {
        if (isset($this->metadata[$metadata->getEntityClass()])) {
            throw new MetadataException(sprintf('Metadata for entity "%s" is already added.', $metadata->getEntityClass()));
        }

        $this->metadata[$metadata->getEntityClass()] = $metadata;
    }
782139
public function setMetadata($author, $name, $value)
    {
        $this->metadata[$this->arrayKey($author)][$name] = $value;

        return $this;
    }
1019955
public static function setVal($metaKey, $elementKey, $elementId, $value)
    {
        $data = self::create()
            ->filterByMetaKey($metaKey)
            ->filterByElementKey($elementKey)
            ->filterByElementId($elementId)
            ->findOne()
        ;

        if (null === $data) {
            $data = new MetaData();
            $data->setMetaKey($metaKey);
            $data->setElementKey($elementKey);
            $data->setElementId($elementId);
        }

        $data->setValue($value);

        $data->save();
    }
10884
public function save($data, $id, $tags = array(), $specificLifetime = false)
    {
        $result = parent::save($data, $id, array(), $specificLifetime);
        if ($tags) {
            if (!method_exists($this->_handle, 'tag_add')) {
                \Zend_Cache::throwException('Method tag_add() is not supported by the PHP memcached extension!');
            }
            foreach ($tags as $tag) {
                $this->_handle->tag_add($tag, $id);
            }
            return true;
        }
        return $result;
    }
258755
protected function writeObject($path, $content, array $metadata)
	{
		try {
			if (\is_resource($content)) {
				$id = $this->client->storeFile($content, $metadata);
			} else {
				$id = $this->client->storeBytes($content, $metadata);
			}
		} catch (MongoGridFSException $e) {
			return false;
		}

		$file = $this->client->findOne(['_id' => $id]);

		return $this->normalizeGridFSFile($file, $path);
	}
1301194
protected function setPropertyMetadata($key, PropertyMetadataInterface $metadata)
    {
        $metadata->merge($this);
        $this->properties[$key] = $metadata;

        return $this;
    }