Write data to cache

@param string $key The cache id
@param mixed $data Data
@return bool
961207
public function write($key, $data) {
        $cache = Zend_Registry::get('CacheFrontend');
        // include the current version in the cached results
        $version = (int)$cache->load($this->_versionKey);
        // save the data to cache but include the version number
        return $cache->save(
            array(
                'data' => $data,
                'version' => $version
            ),
            $key
        );
    }
70315
public function put($key, $data)
    {
        $filename = $this->getKeyCode($key);
        $data = json_encode($data);
        $this->write($data, $filename);
    }
42876
public function write($id, $data) {
    // TODO: Implement locking. b/7701850
    return $this->memcacheContainer->set(
        self::SESSION_PREFIX . $id, $data, $this->expire);
  }
1272823
protected function set($key, $data, $expire) {
		$this->memcache->set($key, $data, null, $expire);
	}
1280314
public function write($data)
    {
        if (!$this->alive) {
            Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
            return false;
        }
        if (!isset($this->bevWrite)) {
            return false;
        }
        if (!mb_orig_strlen($data)) {
            return true;
        }
        $this->writing = true;
        Daemon::$noError = true;
        if (!$this->bevWrite->write($data) || !Daemon::$noError) {
            $this->close();
            return false;
        }
        return true;
    }
546977
private function add_record($key, $data)
    {
        if ($this->type == 'memcache') {
            $result = $this->db->replace($key, $data, MEMCACHE_COMPRESSED, $this->ttl);

            if (!$result) {
                $result = $this->db->set($key, $data, MEMCACHE_COMPRESSED, $this->ttl);
            }
        }
        else if ($this->type == 'apc') {
            if (apc_exists($key)) {
                apc_delete($key);
            }

            $result = apc_store($key, $data, $this->ttl);
        }

        if ($this->debug) {
            $this->debug('set', $key, $data, $result);
        }

        return $result;
    }
75350
public function set($key, $data) {
        $this->ensure_path_exists();
        $filename = $key.'.cache';
        $file = $this->file_path_for_key($key, true);
        $result = $this->write_file($file, $this->prep_data_before_save($data));
        if (!$result) {
            // Couldn't write the file.
            return false;
        }
        // Record the key if required.
        if ($this->prescan) {
            $this->keys[$filename] = cache::now() + 1;
        }
        // Return true.. it all worked **miracles**.
        return true;
    }
1287465
protected function addData($key, $data = null)
    {
        $this->data[self::RS_KEY_DATA]->{$key} = $data;
    }
440018
public static function array_delete(array &$data, $key){
		if(array_key_exists($key, $data)){
			$value = $data[$key];
			unset($data[$key]);
			return $value;
		}
	}
125326
public function set(string $key, $data)
    {
        $this->assertLocked();

        $this->data[$key] = $data;
    }
37047
public function write($data) : bool
    {
        $success = false;

        if ($this->isFile() && $this->isWriteable()) {
            $success = file_put_contents($this->realPath, $data) !== false;
        }

        return $success;
    }
642053
public function save(array $data, $key)
    {
        $this->redis->set($this->decorateKey($key), $data);
    }
905409
private function store($key, $data) 
    {
        $cachePath = $this->getCachePath($key);
        $cacheDir  = dirname($cachePath);
    
        if(!is_dir($cacheDir) && !@mkdir($cacheDir, 0755, true)) {
            throw new \wf\cache\Exception("Could not make cache directory");
        }
            
        if($this->isCompress && function_exists('gzdeflate') && function_exists('gzinflate')) {
            $data['value'] = gzdeflate($data['value']);
        }
        
        $text = "<?php\n# Auto generate by windwork cache engine,please don't edit me.\nreturn " . var_export($data, true) . ';';
        return @file_put_contents($cachePath, $text);
    }
1012098
protected function _putData($key, $data)
    {
        $bool = $this->_validateDataKey($key, $data);
        if (!$bool) {
            return $this;
        }

        $hasData = $this->has($key);
        if ($this->_setPreparationOn) {
            $data = $this->_dataPreparation(
                $key,
                $data,
                $this->_dataPreparationCallbacks
            );
        }

        if (!$hasData
            || ($hasData && $this->_comparator($this->_DATA[$key], $data, '!=='))
        ) {
            $this->_changeData($key, $data, $hasData);
        }

        return $this;
    }
1139722
public function write(string $key, $data, int $ttl = 0): bool
    {
        $ttl = ((int)$ttl <= 0) ? 0 : ((int)$ttl + time());
        $file = $this->cacheFile($key);
        $data = var_export(['ttl' => $ttl, 'data' => serialize($data)], true);
        $data = "<?php\n\rreturn " . preg_replace('/\s=>\s(\n\s+)array\s\(\n/', " => array (\n", $data) . ';';

        return $this->fileWrite($file, $data);
    }
498765
private function save($key, $data)
    {
        $path = $this->getPath($key);

        if (isset($this->locks[$key])) {
            $fp = $this->locks[$key];
            @ftruncate($fp, 0);
            @fseek($fp, 0);
            $len = @fwrite($fp, $data);
            if (\strlen($data) !== $len) {
                @ftruncate($fp, 0);

                return false;
            }
        } else {
            if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
                return false;
            }

            $tmpFile = tempnam(\dirname($path), basename($path));
            if (false === $fp = @fopen($tmpFile, 'wb')) {
                @unlink($tmpFile);

                return false;
            }
            @fwrite($fp, $data);
            @fclose($fp);

            if ($data != file_get_contents($tmpFile)) {
                @unlink($tmpFile);

                return false;
            }

            if (false === @rename($tmpFile, $path)) {
                @unlink($tmpFile);

                return false;
            }
        }

        @chmod($path, 0666 & ~umask());
    }
135286
protected function cacheData($key, $data, $config = [])
    {
        $this->cache->set($key, $data, $config['expire']);
    }