Caches the HTTP response body into database

@param string $key A unique key for storing the data, e.g. request URI
@param string $data The data itself, e.g. XML data
@param int $lifetime How long the entry should be valid
322061
protected function writeCache($key, &$data, $lifetime)
    {
        $this->cacheManager->set($key, $data, [], $lifetime);
    }
208410
public function save($key, $data, $lifeTime)
    {
        //$lifeTime nie jest używany w tym backendzie
        //zapis pliku
        file_put_contents($this->_cache->getConfig()->path . '/' . $key, $data);
        return true;
    }
708183
public function push($key, $data) {
		$keysData = $this->getKeysData();
		$this->clearExpiredKeys($keysData);
		$keysData[$key] = array(
			'time' => time(),
			'data' => $data
		);
		$this->saveKeysData($keysData);
	}
1042134
private function _prepareData($data, $lifetime, $priority)
    {
        $lt = $lifetime;
        if ($lt === null) {
            $lt = 9999999999;
        }
        return serialize(array(
            'data' => $data,
            'lifetime' => $lifetime,
            'expire' => time() + $lt,
            'priority' => $priority
        ));
    }
1147758
public function getCache($key)
    {
        if ($this->sqlInitialized()) {
            if ($this->sql) {
                $_key = $this->sql->real_escape_string($key);
                if ($this->lifetime == self::IMMORTAL_LIFETIME) {
                    if ($response = $this->sql->query("
                        SELECT *
                            FROM `{$this->table}`
                            WHERE
                                `{$this->key}` = '$_key' AND
                                `expire` IS NULL
                    ")) {
                        if ($cache = $response->fetch_assoc()) {
                            return unserialize($cache[$this->cache]);
                        }
                    }
                } else {
                    $liveCache = date('Y-m-d H:i:s', time() - $this->lifetime);
                    if ($response = $this->sql->query("
                        SELECT *
                            FROM `{$this->table}`
                            WHERE
                                `{$this->key}` = '$_key' AND (
                                    (
                                        `timestamp` > '{$liveCache}' AND
                                        `expire` IS NULL
                                    ) OR (
                                        `expire` > NOW()
                                    )
                                )
                    ")) {
                        if ($cache = $response->fetch_assoc()) {
                            return unserialize($cache[$this->cache]);
                        }
                    }
                }
            }
            return false;
        }
    }
672450
public function save($key, $data, $lifeTime)
    {
        //zapis w APC
        \apcu_store($this->_namespace . $key, $data, $lifeTime);
        return true;
    }
1058616
protected function cacheSet($id, $data, $lifetime = null, $tags = null) {
		return $this->getCacheFrontend()->set($id, $data, $lifetime, $tags);
	}
12340
public function save($oldText, $newText, $data, $lifeTime = 0)
    {
        return $this->cacheProvider->save($this->getHashKey($oldText, $newText), $data, $lifeTime);
    }
484760
public function store($key, $data, $lifetime = 0)
    {
        $file_path = $this->getFilePath($key);
        $dir = \dirname($file_path);

        if (!is_dir($dir)) {
            try {
                \mkdir($dir, 0777, true);
            } catch (Exception $e) {
                throw new \Exception('Could create cache directory: ' . $file_path . " - " . $e->getMessage());
            }
        }

        try {
            $fh = \fopen($file_path, 'a+');
        } catch (\Exception $e) {
            throw new \Exception('Could not write to cache: ' . $file_path . " - " . $e->getMessage());
        }

        //exclusive lock
        \flock($fh, LOCK_EX);

        \fseek($fh, 0);

        \ftruncate($fh, 0);

        if ($lifetime != 0) {
            $lifetime = time() + $lifetime;
        }

        $data = \serialize(array($lifetime, $data));

        if (\fwrite($fh, $data) === false) {
            throw new \Exception('Could not write to cache: ' . $file_path);
        }

        \fclose($fh);

        if ($key != $this->catalog_key) {
            $this->catalogKeyAdd($key, $lifetime);
        }
        return true;
    }
1021834
public function set($key, $value, $lifeTime = 3600)
    {
        if (!$this->isEnabled()) {
            return false;
        }

        return eaccelerator_put($this->prefix() . $key, serialize($value), $lifeTime);
    }
615864
public function keep($key)
	{
		if (isset($this->data[static::EXPIRE_DATA_KEY][$key]))
		{
			$this->data[static::EXPIRE_DATA_KEY][$key][1] = static::EXPIRE_STATE_NEW;
			return true;
		}

		return false;
	}
384501
public function update_cache($key, $data)
    {
        if ($cache = $this->get_cache_engine()) {
            $cache->set($key, $data);
        }
    }
121746
public function write($key, $data)
    {
        apcu_store($this->_prefix . $key, $data, $this->_ttl);
    }
807529
public function cached($key) {
        global $USER;
        $this->ensure_session_cache_initialised();
        if (!array_key_exists($key, $this->session) || !is_array($this->session[$key]) || $this->session[$key][self::CACHEUSERID]!=$USER->id || $this->session[$key][self::CACHETIME] < $this->timeout) {
            return false;
        }
        return true;
    }
781604
protected function cacheData(string $key, string $data) : string
    {
        $this->cache[$key] = $data;

        return $data;
    }
988264
public function load($key)
    {
        if ($key !== null) {
            $this->session = $this->storage->load($key);
        }

        // If the session doesn't exist or is invalid.
        if (is_null($this->session) || static::expired($this->session)) {
            $this->exists = false;
            $this->session = $this->storage->fresh();
        }

        // A CSRF token is stored in every session to protect
        // the application from cross-site request
        if (!$this->has(Session::CSRF)) {
            $this->put(Session::CSRF, Character::random(40));
        }
    }
1165839
public function setCookie( $key, $val, $lifetime = 2592000, $track = TSINT_COOKIE_TRACK ) {
		// Validate cookie name
		$name = $this->getCookieName( $key );
		if ( !$name ) {
			return false;
		}

		$val = strval( $val );
		$lifetime = intval( $lifetime );
		$expire = time() + $lifetime;

		// Set a 30-day domain-wide cookie
		setcookie( $name, $val, $expire, '/' );

		// In order to keep track of the expiration date, we set another cookie
		if ( $track === TSINT_COOKIE_TRACK ) {
			$this->setExpiryTrackerCookie( $lifetime );
		}

		return true;
	}