Update an existing key with a given value.
@param strint $key
@param string $value
@param int $ttl
@param array $condition The extra condition for updating
@return array $body
@throws KeyNotFoundException
434056
public function update($key, $value, $ttl = 0, $condition = array())
    {
        $extra = array('prevExist' => 'true');

        if ($condition) {
            $extra = array_merge($extra, $condition);
        }
        $body = $this->set($key, $value, $ttl, $extra);
        if (isset($body['errorCode'])) {
            throw new KeyNotFoundException($body['message'], $body['errorCode']);
        }
        return $body;
    }
677625
public function write($key, $value, $ttl = 0)
    {
        $ttl = ((int) $ttl <= 0) ? 0 : ((int) $ttl + time());

        try {
            $this->delete($key);

            return $this->db
                    ->insert(array(
                        $this->columns['key'] => $this->prefix . $key,
                        $this->columns['data'] => serialize($value),
                        $this->columns['ttl'] => $ttl,
                    ))
                    ->into($this->table);
        } catch (PDOException $e) {
            return false;
        }
    }
336508
public function set($key, $value, $ttl)
    {
        return self::getCacheDriver()->set($key, $value, $ttl);
    }
1176534
private function setToCache($key, $value, $ttl = 0)
    {
        if (!$this->cache()) {
            return;
        }

        $params = func_get_args();

        // Use default TTL if none is provided
        if ($this->cacheTTL && func_num_args() < 3) {
            array_push($params, $this->cacheTTL);
        }

        call_user_func_array([$this->cache(), 'set'], $params);
    }
1141041
public function set($key, $value, $ttl = null)
    {
        try {
            $this->_set($key, $value, $ttl);
        } catch (RootException $e) {
            if ($e instanceof ContainerExceptionInterface) {
                throw $e;
            }

            throw $this->_createContainerException($this->__('Could not set data'), null, $e, $this);
        }
    }
789101
public function set($key, $value, $ttl = null, $nx = false)
    {
        $this->log(__FUNCTION__, $key);
        return $this->persistence->set($key, $value, $ttl, $nx);
    }
554961
public function setWithInOrderKey($dir, $value, $ttl = 0, $condition = array())
    {
        $data = array('value' => $value);

        if ($ttl) {
            $data['ttl'] = $ttl;
        }

        $request = $this->guzzleclient->post($this->buildKeyUri($dir), null, $data, array(
            'query' => $condition
        ));
        $response = $request->send();
        $body = $response->json();
        return $body;
    }
242514
public function set($key, $value, $ttl)
    {
        $file = array(
            'key'   => $key,
            'value' => serialize($value),
            'ttl'   => $ttl,
            'ctime' => time(),
        );

        if ($this->isSafe() && !empty($key)) {
            return (bool) file_put_contents($this->getFilename($key), serialize($file));
        }

        return false;
    }
1326507
public function append($key, $value, $ttl=null)
    {
        return $this->getStorage()->append($key, $value, $ttl);
    }
1178429
public function set($key, $value, $ttl = 0) {
        if (is_resource($value)) {
            return false;
        }
        $used_key = $this->getUsedKey($key);
        $res = $this->redis->set($used_key, $this->esc($value));

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

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

        return ($this->redis->expire($used_key, $ttl) == 1);
    }
818596
protected function save($key, $value, $ttl) {
        $this->doctrineCacheInstance->save($key, $value, $ttl);
    }
978821
public function saveItem($key, $value, $ttl = null)
    {
        $cache = [
            'start' => time(),
            'ttl'   => ($ttl !== null) ? (int) $ttl : $this->ttl,
            'value' => $value,
        ];
        if ($cache['ttl'] != 0) {
            $this->redis->set($key, json_encode($cache), $cache['ttl']);
        } else {
            $this->redis->set($key, json_encode($cache));
        }

        return $this;
    }
642184
public function set($key, $value, $ttl = 0)
    {
        $ttl = $this->fromDefaultTtl($ttl);

        if ($ttl >= 0) {
            if ($this->isAvailable()) {
                $this->redis->set($key, $this->storageDataStructure($value));

                if ($ttl > 0) {
                    $this->redis->expire($key, $ttl);
                }
            }

            $this->setChain($key, $value, $ttl);
        }

        return $this;
    }
502956
public function set($key, $value, $ttl, $time)
    {
        $this->data[$key] = array(
            self::CACHE_PARAM_VALUE => $value,
            self::CACHE_PARAM_CREATED => $time,
            self::CACHE_PARAM_TTL => $ttl
        );

        return $this;
    }
2710
protected function doSet(string $key, $value, int $ttl = 0)
    {
        if ($ttl > 0) {
            $ttl = \time() + $ttl;
        }

        $filename = $this->getFilename($key);
        $content = '<?php /* ' . Serialize::encode([
                'value' => $value,
                'expire' => $ttl,
            ]) . ' */';

        return $this->storage->put($filename, $content);
    }
615311
public function set($key, $value, $ttl = null)
	{
		return $this->_set($key, $value, $ttl, false);
	}
621782
public function set($key, $value, $ttl = null)
    {
        $this->values[$key] = [];

        $this->values[$key][static::VALUE] = $value;
        $this->values[$key][static::TTL] = $ttl;
        $this->values[$key][static::CREATE_TIME] = time();

        return true;
    }