Caches the value into redis with errors suppressed.

@param string $key       The key.
@param string $value     The value.
@param int    $cacheTime The optional cache time

@return void
2126
private function cache(string $key, string $value, int $cacheTime = null)
    {
        try {
            $this->client->set($key, $value);

            if ($cacheTime !== null) {
                $this->client->expire($key, $cacheTime);
            }
        } catch (\Exception $e) {
            // We don't want exceptions in accessing the cache to break functionality.
            // The cache should be as transparent as possible.
            // If insight is needed into these exceptions,
            // a better way would be by notifying an observer with the errors.
        }
    }
504079
public function write($key, $value)
    {
        $key = $this->_key($key);

        if (!is_int($value)) {
            $value = serialize($value);
        }

        $duration = $this->_config['duration'];
        if ($duration === 0) {
            return $this->_Redis->set($key, $value);
        }

        return $this->_Redis->setEx($key, $duration, $value);
    }
1338589
protected function setCachedValue($key, $value)
    {
        $this->cache->setPrefix($this->dataProvider->getCachePrefix());
        return $this->cache->set($key, $value);
    }
1149209
public function set($key, $value, $timeToLive = null) {
		$filename = $this->getFileName($key);
		//$this->log->trace("Storing value in cache: key '$key', value '".var_export($value, true)."'");
		if ($this->log) {
			if ($this->log instanceof LoggerInterface) {
				$this->log->info("Storing value in cache: key '{key}'", array('key'=>$key));
			} else {
				$this->log->trace("Storing value in cache: key '$key'");
			}
		}

        $oldUmask = umask(0);
		
		if (!is_writable($filename)) {
			if (!file_exists($this->getDirectory())) {
				mkdir($this->getDirectory(), 0777, true);
			}
		}
		
		if ($timeToLive == null) {
			if (empty($this->defaultTimeToLive)) {
				$timeOut = 0;
			} else {
				$timeOut = time() + $this->defaultTimeToLive;
			}
		} else {
			$timeOut = time() + $timeToLive;
		}
		
		$fp = fopen($filename, "w");
		flock($fp, LOCK_EX);
		fwrite($fp, $timeOut."\n");
		fwrite($fp, serialize($value));
		fflush($fp);
		flock($fp, LOCK_UN);
		fclose($fp);
        // Cache is shared with group, not with the rest of the world.
        chmod($filename, 0660);

        umask($oldUmask);
	}
1308219
public function set($key, $value, $expire = 600) {
        $this->redis->setex($this->formatKey($key), $expire, $this->formatValue($value));
    }
323364
public function saveInCache($key, $value)
  {
    $this->deleteFromCache($key);
    $file = $this->cachePath . $this->getEncodedKey($key);
    file_put_contents($file, serialize($value), LOCK_EX);
  }
1162148
public function set($key, $value)
    {
        $this->nestedKeyCache = [];

        if ($this->isNestedKey($key)) {
            $this->setNestedValueByKey($key, $value);

            return;
        }

        $this->items[$key] = $value;
    }
235471
public function store($key, $value, $expiry=0) {
		if ($expiry == 0) {
			$expiry = $this->expiry;
		}
		$entry = new CacheItem();

		$entry->value = serialize($value);
		$entry->expireAt = time() + $expiry;
		$data = serialize($entry);

		$this->store->store($key, $data);

		$this->items[$key] = $entry;
	}
344258
public function set(string $key, $value)
    {
        $array = &$this->input;
        $keys = explode('.', $key);

        while (count($keys) > 1) {
            $k = array_shift($keys);
            if (!isset($array[$k]) || ! is_array($array[$k])) {
                $array[$k] = [];
            }
            $array = &$array[$k];
        }

        $array[array_shift($keys)] = $value;
        $this->cache[$key] = &$value;
    }
867134
public function setToCache($key, $value)
    {
        $fileName = $this->getCacheFilePath($key);
        $cacheDirectory = $this->getCacheDir();

        $tmpFile = $cacheDirectory . "/" . basename($fileName) . uniqid('.temp', true) . '.txt';
        file_put_contents($tmpFile, serialize($value), LOCK_EX);

        rename($tmpFile, $fileName);
    }
262286
public function set($key, $value, $timeToLive = null) {
		$filename = $this->getFileName($key);
		//$this->log->trace("Storing value in cache: key '$key', value '".var_export($value, true)."'");
		if ($this->log) {
			if ($this->log instanceof LoggerInterface) {
				$this->log->info("Storing value in cache: key '{key}'", array('key'=>$key));
			} else {
				$this->log->trace("Storing value in cache: key '$key'");
			}
		}

        $oldUmask = umask(0);

		if (!is_writable($filename)) {
			if (!file_exists($this->getDirectory())) {
				mkdir($this->getDirectory(), 0777, true);
			}
		}
		
		if ($timeToLive == null) {
			if (empty($this->defaultTimeToLive)) {
				$timeOut = 0;
			} else {
				$timeOut = time() + $this->defaultTimeToLive;
			}
		} else {
			$timeOut = time() + $timeToLive;
		}

		$data = array(
			'lifetime'  => $timeOut,
			'data'      => $value
		);

        $serializeData = serialize($data);
        if(strpos($serializeData, 'r:') !== false || (is_object($value) && !method_exists($value, '__set_state'))){
            $code   = sprintf('<?php return unserialize(%s);', var_export($serializeData, true));
            file_put_contents($filename, $code);
        }else{
            $data  = var_export($data, true);
            $code   = sprintf('<?php return %s;', $data);
            file_put_contents($filename, $code);
        }

        // Cache is shared with group, not with the rest of the world.
        chmod($filename, 0660);

        umask($oldUmask);
	}
1072269
public function put($key, $value, $minutes)
	{
		xcache_set($this->prefix.$key, $value, $minutes * 60);
	}
846527
public function set($key, $value)
    {
        $item = $this->psr6Cache->getItem($key);
        $item->set($value);

        $this->psr6Cache->save($item);
    }
136
public function put($key, $value, $minutes)
    {
        $this->forever($key, $value);
        $this->redis->expire($key, $minutes * 60);
    }
687397
private function setCache(
        string $key, $value, ?int $expires
    ): void {
        $cache = $this->client->getItem($key);
        $cache->set($value);
        $cache->expiresAfter($expires);
        $this->client->save($cache);
    }
707452
public function setCache($key, $value) {
        $this->_cache[$this->createCacheKey($key)] = $value;

        return $value;
    }
328570
public function set($key, $value, $seconds, $strict = true) {
        $set = $this->memcached->set($key, $value, $seconds);
        if (!$set && $strict) {
            throw new CacheSetException($key);
        }
    }