@param $key
@param $value
@param $ttl

@return bool
336508
public function set($key, $value, $ttl)
    {
        return self::getCacheDriver()->set($key, $value, $ttl);
    }
539488
public function set($key, $value, $ttl = self::DEFAULT_TTL)
    {
        $md5 = md5($key);
        $folderPath = $this->getFolderPathFromMd5($md5);
        $create = $this->helper->createPath($this->path, $folderPath);
        if (!$create) {
            return false;
        }
        $basePaths = $this->path . self::DS . $folderPath;
        $path = $basePaths . self::DS . $this->prefix . $md5;

        $handle = fopen($path, 'w');
        if ($handle) {
            $data = time() + $ttl . PHP_EOL . serialize($value);
            $success = fwrite($handle, $data);
            return ($success !== false);
        }

        // @codeCoverageIgnoreStart
        return false;
        // @codeCoverageIgnoreEnd
    }
719020
public function setResult($key, $result, $ttl)
    {
        if (!($ttl instanceof Ttl)) {
            $ttl = new Ttl($ttl);
        }

        $expirationTimestamp = time() + $ttl->getTtl();
        $value = new Value($result, $expirationTimestamp);

        $this->valueStore->set($key, $value, $ttl->getRealTtl());
    }
194925
public function do_set($key, $value, $ttl)
    {
        /** @var \ManaPHP\DbInterface $db */
        $db = $this->_di->getShared($this->_db);

        $hash = md5($key);

        if ($db->query($this->_source)->whereEq('hash', $hash)->exists()) {
            $db->update($this->_source, ['value' => $value, 'ttl' => $ttl, 'expired_time' => time() + $ttl], ['hash' => $hash]);
        } else {
            $db->insert($this->_source, ['hash' => $hash, 'key' => $key, 'value' => $value, 'ttl' => $ttl, 'expired_time' => time() + $ttl]);
        }
    }
1214434
public function has( $key, $ttl = null ) {
		if ( ! $this->enabled ) {
			return false;
		}

		$filename = $this->filename( $key );

		if ( ! file_exists( $filename ) ) {
			return false;
		}

		// use ttl param or global ttl
		if ( null === $ttl ) {
			$ttl = $this->ttl;
		} elseif ( $this->ttl > 0 ) {
			$ttl = min( (int) $ttl, $this->ttl );
		} else {
			$ttl = (int) $ttl;
		}

		//
		if ( $ttl > 0 && ( filemtime( $filename ) + $ttl ) < time() ) {
			if ( $this->ttl > 0 && $ttl >= $this->ttl ) {
				unlink( $filename );
			}
			return false;
		}

		return $filename;
	}
53805
public function set($key, $value, $ttl = false)
    {
        return apc_store($key, $value, (int)$ttl);
    }
1033146
public function saveItem($key, $value, $ttl = null)
    {
        $cache = [
            'start' => time(),
            'ttl'   => ($ttl !== null) ? (int) $ttl : $this->ttl,
            'value' => $value,
        ];

        $this->memcached->set($key, $cache, $cache['ttl']);

        return $this;
    }
526438
public function update($key, $value, $ttl = 0, $condition = [])
    {
        $extra = ['prevExist' => 'true'];

        if ($condition) {
            $extra = array_merge($extra, $condition);
        }

        return $this->set($key, $value, $ttl, $extra);
    }
141021
public function store($key, $value, $ttl = self::DEFAULT_TTL) {
        apc_store($key, $value, (int) $ttl);
        return $value;
    }
661269
public function setWithTtl($key, $value, $ttl) {
        if (is_resource($value))
            return false;

        if ($ttl != 0 && $ttl > 2592000) {
            $ttl -= time();
        }
        if ($ttl <= 0)
            return true;

        $key = $this->getUsedKey($key);
        $res = $this->_connection->set($key, $this->esc($value));

        if ($res !== 'OK') {
            return false;
        }

        return ($this->_connection->expire($key, $ttl) == 1);
    }
56753
protected function setValue($id, $value, $ttl)
    {
        $file = $this->getFile($id);
        if (file_put_contents($file, $value, LOCK_EX)) {
            $ttl = $ttl + time();
            @chmod($file, 0666);
            return @touch($file, $ttl);
        }
        return false;
    }
674691
protected function doSet(string $key, $value, int $ttl = 0)
	{
		if ($ttl > 0) {
			$ttl = \time() + $ttl;
		}

		$filename = $this->getFilename($key);
		$code = '<?php return ';

		if ($ttl > 0) {
			$code .= '(time() > ' . $ttl . ') ? null : ';
		}

		$code .= \var_export($value, true) . ';';

		return $this->writeFile($filename, $code);
	}
906591
public function set($key, $value, $ttl = 2592000)
    {
        if (!self::$instance) {
            self::getInstance();
        }

        return self::$redis->set(CFG_DOMAIN . $key, $value, $ttl);
    }
856852
public function set($key, $value, $ttl = null)
    {
        return $this->driver->set($key, serialize($value), $ttl);
    }
600771
public function set($key, $value, $ttl = self::DEFAULT_TTL)
    {
        if (!$this->hasConnection()) {
            // @codeCoverageIgnoreStart
            return false;
            // @codeCoverageIgnoreEnd
        }

        $flag = null;

        if (!is_bool($value) && !is_int($value) && !is_float($value)) {
            $flag = MEMCACHE_COMPRESSED;
        }

        try {
            return $this->memcache->set($key, $value, $flag, $ttl);
        // @codeCoverageIgnoreStart
        } catch (\Exception $e) {
        }

        return false;
        // @codeCoverageIgnoreEnd
    }
313465
public function set($key, $value, $ttl = 0)
    {
        $this->insertToDatabase($key, $value, $ttl);
        $this->setChain($key, $value, $ttl);

        return $this;
    }
190065
public function saveItem($key, $value, $ttl = null)
    {
        $cache = [
            'start' => time(),
            'ttl'   => ($ttl !== null) ? (int) $ttl : $this->ttl,
            'value' => $value,
        ];

        apcu_store($key, $cache, $cache['ttl']);

        return $this;
    }