Store the expiration time for items we're setting in this request, to
work around APC's behavior of only clearing expires per page request.

@see static::$expires

@param array|string $key
@param int          $ttl
183541
protected function expire($key = array(), $ttl = 0)
    {
        if ($ttl === 0) {
            // when storing indefinitely, there's no point in keeping it around,
            // it won't just expire
            return;
        }

        // $key can be both string (1 key) or array (multiple)
        $keys = (array) $key;

        $time = time() + $ttl;
        foreach ($keys as $key) {
            $this->expires[$key] = $time;
        }
    }
445584
protected function store($key, $var, $ttl = 0)
    {
        if (function_exists('apcu_store')) {
            return apcu_store($key, $var, $ttl);
        }

        return apc_store($key, $var, $ttl);
    }
319852
public function store( $key, $var, $ttl = 0 )
    {
        $data = new ezcCacheMemoryVarStruct( $key, $var, $ttl );
        return apc_store( $key, $data, $ttl );
    }
376448
public function set($key, $data, $expire = 0) {
		$expire = intval($expire);
		return $this->cache->set($this->prefix.$key, $data, $expire);
	}
28932
public function store(Memento\Key $key, $value, $expires = null, $ttl = null)
    {
        $this->__connect($key);

        $hash = null;

        // if no expires specified use default of 5 minutes
        if (!is_numeric($expires)) {
            $expires = self::DEFAULT_EXPIRES;
        }

        // ttl is when the cache is actually okay for deletion
        if (!is_numeric($ttl)) {
            $ttl = $expires;
        }

        // convert to absolute time
        $expires = $expires + time();
        $ttl = $ttl + time();

        // handle arguments based on group or single key
        if ($this->groupKey) {
            $hash = array(
                $this->groupKey->getKey(),
                Memento\Hash::FIELD_VALID,
                serialize(true),
                $key->getKey(),
                serialize($value),
                Memento\Hash::FIELD_EXPIRES,
                $expires,
                Memento\Hash::FIELD_TTL,
                $ttl,
            );
        } else {
            $hash = array(
                $key->getKey(),
                array(
                    Memento\Hash::FIELD_DATA  => serialize($value),
                    Memento\Hash::FIELD_VALID => serialize(true),
                    Memento\Hash::FIELD_EXPIRES  => $expires,
                    Memento\Hash::FIELD_TTL => $ttl,
                )
            );
        }

        if (!is_array($hash)) {
            return false;
        }

        if ($success = call_user_func_array(array($this->redis, 'hmset'), $hash)) {
            $this->setExpires($key, $ttl); // actual redis expires uses ttl value
        }

        return $success;
    }
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;
	}
721905
def set_ttl(self, key, ttl):
        
        return self._client.expire(self.get_key(key), ttl)
1245747
public function save($key, $item, $ttl = null)
    {
        try {
            $this->handler->set($key, $item, $ttl);
        } catch (\Exception $e) {
            return $e->getMessage();
        }
        return true;
    }
1227871
public function setExpires(string $expires)
    {
        if (empty($expires)) {
            Throw new HeaderException('Empty expires is not allowed.');
        }

        $this->expires = $expires;
    }
1257091
public function set($key, $value, $ttl = null)
    {
        return $this->_instance->set($key, $value, $ttl);
    }
910253
public function save($key, $content, $ttl)
    {
        $cacheFile = $this->getCachePath($key);
        $cache = json_encode(['ttl' => (time() + $ttl), 'content' => $content]);

        file_put_contents($cacheFile, $cache);

        return true;
    }
141247
private function setExpiration($expires_in)
    {
        $this->expiresAtTimestamp = time() + $expires_in;
        $this->expiresAt = date('Y-m-d H:i:s', time() + $expires_in);
    }
1362402
public function set($key, $data, $ttl = 3600)
    {
        if (empty($this->memcache)) {
            return false;
        }

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

        $compress = !empty($this->compress) ? MEMCACHE_COMPRESSED : 0;

        return $this->memcache->set($key, $data, $compress, $ttl);
    }
1296490
public function setTtl($key, $ttl) {
        $redis = $this->_getRedisClient();
        $redis->expire($this->_getInternalKey($key), $ttl);
    }
946393
private function setToCache(string $key, $value, $ttl = null): void
    {
        $params = func_get_args();

        // Use default TTL if none is provided
        if ($this->cacheTTL && $ttl === null) {
            array_push($params, $this->cacheTTL);
        }

        call_user_func_array([$this->cache(), 'set'], $params);
    }
247703
public function set($key, $data, $ttl)
    {
        $this->ttl = $ttl;

        $filename = $this->cacheDir . DIRECTORY_SEPARATOR . $this->processKey($key);

        return $this->safelyWriteData($filename, 'w', serialize($data));
    }
173202
public function do_set($key, $value, $ttl)
    {
        $redis = is_object($this->_redis) ? $this->_redis : $this->_getRedis();
        $redis->set($this->_prefix . $key, $value, $ttl);
    }