Store the data into the cache

@param  string         $id       ID of the stored data
@param  mixed          $data     Stored data
@param  int            $lifetime Lifetime in seconds
@param  string | array $tag
@return bool
544767
public function set($id, $data, $lifetime = 0, $tags = null) {
		if ($tags === null) {
			return $this->getBackend()->set($id, $data, $lifetime);
		}
		
		$tagBackend = $this->getTagHolderBackend();
		
		if (is_array($tags)) {
			$tags      = array_map([$this, 'prepareTag'], array_values($tags));
			$tagsData  = $tagBackend->getMany($tags);
			$tagsCount = count($tagsData, COUNT_RECURSIVE);
			
			if (empty($tagsData)) {
				$tagsData = array_fill_keys($tags, [$id]);
			} else {
				foreach ($tags as $tag) {
					if (empty($tagsData[$tag])) {
						$tagsData[$tag] = [$id];
					} else if (! in_array($id, $tagsData[$tag], true)) {
						$tagsData[$tag][] = $id;
					}
				}
			}
			
			if (count($tagsData, COUNT_RECURSIVE) !== $tagsCount) {
				$tagBackend->setMany($tagsData, $lifetime);
			}
		} else {
			$tag      = $this->prepareTag($tags);
			$tagData  = $tagBackend->get($tag);
			$tagCount = count($tagData);
			
			if (empty($tagData)) {
				$tagData = [$id];
			} else if (! in_array($id, $tagData, true)) {
				$tagData[] = $id;
			}
			
			if (count($tagData) !== $tagCount) {
				$tagBackend->set($tag, $tagData, 0);
			}
		}
		
		return $this->getBackend()->set($id, $data, $lifetime);
	}
1314026
public function save(string $id, array $data)
    {
        $this->setFile($id);
        if ($this->file) {
            if (file_exists($this->file)) {
                $this->update($id, $data);
            } else {
                $this->add($id, $data);
            }
        }
    }
602891
public function write($id, $data, $next)
    {
        $item = new MemoryItem($data);
        $this->cache[$id] = $item;

        return $next($id, $data);
    }
322061
protected function writeCache($key, &$data, $lifetime)
    {
        $this->cacheManager->set($key, $data, [], $lifetime);
    }
1135662
public function set($id, $data, $lifetime = 0) {
		if ($lifetime === 0) {
			$expire = '0000000000';
		} else {
			$expire = time() + $lifetime;
		}
		
		$options = 0;
		
		if (! is_string($data)) {
			$data = serialize($data);
			$options += self::OPTION_SERIALIZED;
		}
		
		if ($this->compression
		&& ($this->compressionTreshold === 0
		|| ($this->compressionTreshold > 0 && strlen($data) > $this->compressionTreshold))) {
			$data = gzcompress($data, $this->compressionLevel);
			$options += self::OPTION_COMPRESSED;
		}
		
		$options = sprintf('%03d', $options);
		$path    = $this->preparePath($id);
		$content = $expire . ';' . $options . ';' . $data;
		
		$result = file_put_contents($path, $content, LOCK_EX);
		
		if ($result === false) {
			throw new OperationFailed('Unable to puth the cache content to: ' . $path);
		}
		
		return true;
	}
656429
public function save($data, $key, $lifetime = null)
    {
        //bufor nieaktywny
        if (!$this->isActive()) {
            return true;
        }
        //brak podanego klucza (użycie domyślnego z cache)
        if (!$lifetime) {
            //jeśli null - użycie domyślnego, jeśli zero lub false to maksymalny
            $lifetime = $lifetime === null ? $this->_config->lifetime : ($lifetime == 0 ? self::MAX_LIFETIME : $lifetime);
        }
        //zapis w rejestrze
        $this->getRegistry()->setOption($key, $data);
        //zapis w handlerzie
        return (bool)$this->_handler->save($key, $this->_setCacheData($data, time() + $lifetime), $lifetime);
    }
1291612
public function write($id, $data)
    {
        $this->redis->set($this->prefix . $id, $data);

        $this->redis->expire($this->prefix . $id, $this->maxLifetime);

        return true;
    }
1339351
public function saveById($id, $data)
    {
        $subData = array();
        foreach (array_keys($this->subAttributeList) as $subKey) {
            $subData[$subKey] = null;
            if (isset($data[$subKey])) {
                $subData[$subKey] = $data[$subKey];
                unset($data[$subKey]);
            }
        }
        $id = parent::saveById($id, $data);
        foreach (array_keys($this->subAttributeList) as $subKey) {
            $this->saveSubAttributeById($id, $subKey, $subData[$subKey]);
        }
        return $id;
    }
559741
public function write($id, $data): bool
    {
        return $this->handler->set($this->prepareId($id), $data, (int)$this->ttl);
    }
170133
public function set($id, $data, $lifeTime = 0)
    {
        if ($lifeTime > (int) 2592000) {
            $lifeTime = time() + $lifeTime;
        }

        return $this->memcache->add($id, $data, CacheFlags::CACHE_COMPRESSED, (int) $lifeTime);
    }
1000123
public function write($id, $data)
    {
        $access = time();
        $this->session_id = (string) $id;
        $this->access = $access;
        $this->data = $data;
        $this->save();

        return true;
    }
296336
public function setCache($key, $data, $lifetimeInSeconds = false)
    {
        if ($this->sqlInitialized()) {
            if ($this->sql) {
                /* escape query data */
                $_key = $this->sql->real_escape_string($key);
                $_data = $this->sql->real_escape_string(serialize($data));
                $_expire = $this->getExpirationTimestamp($lifetimeInSeconds);

                $response = $this->sql->query("
                    SELECT *
                        FROM `{$this->table}`
                        WHERE
                            `{$this->key}` = '$_key'
                ");
                if ($response->fetch_assoc()) {
                    if ($this->sql->query("
                        UPDATE
                            `{$this->table}`
                            SET
                                `{$this->cache}` = '$_data',
                                `expire` = " . ($_expire === false ? 'NULL' : "'$_expire'") . "
                            WHERE
                                `{$this->key}` = '$_key'
                    ")) {
                        return true;
                    } else {
                        throw new SimpleCache_Exception(
                            'Could not update existing cache data. ' . $this->sql->error,
                            SimpleCache_Exception::CACHE_WRITE
                        );
                    }
                } elseif ($this->sql->query("
                    INSERT
                        INTO `{$this->table}`
                        (
                            `{$this->key}`,
                            `{$this->cache}`
                            " . ($_expire === false ? '' : ", `expire`") . "
                        ) VALUES (
                            '$_key',
                            '$_data'
                            " . ($_expire === false ? '' : ", '$_expire'") . "
                        )
                ")) {
                    return true;
                } else {
                    throw new SimpleCache_Exception(
                        'Could not insert new cache data. ' . $this->sql->error,
                        SimpleCache_Exception::CACHE_WRITE
                    );
                }
            }
            return false;
        }
    }
768567
public function save($id, $data, $lifetime = null)
    {
        if ($this->enabled) {
            if ($lifetime === null) {
                $lifetime = $this->getLifetime();
            }
            $this->driver->save($id, $data, $lifetime);
        }
    }
157803
public function save($id, $data, $ttl = 60, $raw = FALSE)
	{
		return wincache_ucache_set($id, $data, $ttl);
	}
984404
public function add($id, $data = 1)
    {
        try {
            return $this->resource->hSet(static::CACHE_KEY, $id, $data);
        } catch (ConnectionException $e) {
            return false;
        }
    }
644752
public function setMany(array $data, $lifetime = null, $tags = null) {
		$backend = $this->getBackend();
		
		if ($tags !== null) {
			if (! $backend instanceof TaggableInterface) {
				throw new NoTagsSupported('Unable to set the data with the tag(s) due to the tags does not supported by the backend "' . get_class($backend) . '"');
			}
			
			if (is_array($tags)) {
				$tags = array_map([$this, 'prepareId'], $tags);
			} else {
				$tags = $this->prepareId($tags);
			}
		}
		
		$ids  = array_map([$this, 'prepareId'], array_keys($data));
		$data = array_combine($ids, array_values($data));
		
		if ($lifetime === null) {
			$lifetime = $this->_defaultLifetime;
		}
		
		return $backend->setMany($data, $lifetime, $tags);
	}
1317756
private function _registerTag($id, $tag) {
        $res = $this->_query("DELETE FROM TAG WHERE name='$tag' AND id='$id'");
        $res = $this->_query("INSERT INTO tag (name, id) VALUES ('$tag', '$id')");
        if (!$res) {
            $this->_log("Zend_Cache_Backend_Sqlite::_registerTag() : impossible to register tag=$tag on id=$id");
            return false;
        }
        return true;
    }