set string

@param   string     $key
@param   string|int $value
@param   int $timeout
552230
public function set($key, $value, $timeout = 0)
    {
        if (is_int($timeout) && $timeout > 0) {
            $this->driver->set($key, (string)$value, $timeout);
        } else {
            $this->driver->set($key, (string)$value);
        }
    }
1371105
function set_timeout($timeout) {
        if (!is_integer($timeout)) {
            if (is_numeric($timeout)) {
                $this->timeout = (integer)$timeout;
                return true;
            }
            return false;
        }
        $this->timeout = $timeout;
        return true;
    }
768674
function set($value, $timeout = 600)
	{
		if(!($memcache = \B2\Cfg::get('memcached_instance')))
			return $this->last_value = $value;

//		$memcache = &new Memcache();
//		$memcache->connect(\B2\Cfg::get('memcached')) or debug_exit('Could not connect memcache');

		if($value = NULL || $timeout == 0)
			$memcache->delete($this->last_key);
		else
			$memcache->set($this->last_key, $value, true, $timeout);

	}
882024
def set(self, key, value, timeout=None):
        
        key = self.make_key(key)
        if timeout is None:
            timeout = self.default_timeout

        if self.debug:
            return True

        pickled_value = pickle.dumps(value)
        self.metrics['writes'] += 1
        if timeout:
            return self.database.setex(key, int(timeout), pickled_value)
        else:
            return self.database.set(key, pickled_value)
885090
public function put($key, $value, $minutes = null)
    {
        $this->cache->put($key, $value, $minutes);
    }
417415
public function timeout($timeout = null)
    {
        // Return value
        if (empty($timeout)) {
            return $this->timeout;
        }

        // Set value
        $this->timeout = $timeout;

        return $this;
    }
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);
	}
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]);
        }
    }
905007
private function setValue($key, $value)
    {
        $this->$key = $value;

        if ($key == 'expires_in') $this->setExpiration($value);
    }
489449
public void set(long value) throws MemcachedException, InterruptedException, TimeoutException {
    this.memcachedClient.set(this.key, 0, String.valueOf(value));
  }
224357
public function setRequestTimeout($timeout)
    {
        if (!is_int($timeout) || $timeout < 0) {
            throw new Exception("Invalid value supplied for request timeout: $timeout");
        }

        $this->requestTimeout = $timeout;
        return $this;
    }
669885
public function put($key, $value, $minutes)
    {
        $this->connection()->setex(
            $this->prefix.$key, (int) max(1, $minutes * 60), $this->serialize($value)
        );
    }
108776
public function set(CacheKey $key, $value, $sessionLength = null) {

        if ($sessionLength == null) {
            $sessionLength = $this->timeThreshold;
        }

        $sKey = $this->getKey($key);

        if (is_array($value) || is_object($value)) {
            $value = serialize($value);
        }

        $this->redis->set($sKey, $value);

        if (!empty($sessionLength) && $sessionLength > 0) {
            $this->redis->expire($sKey, $sessionLength);
        }
    }
934676
public function put($key, $value, $minutes)
	{
		$minutes = $this->getMinutes($minutes);

		$this->store->put($key, $value, $minutes);
	}
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);
	}
147491
public function setTimeout($timeout)
    {
        if ($timeout === null) {
            $this->timeout = null;
            $this->onConfigChanged();
            return;
        }

        $timeout = (int)$timeout;

        if ($timeout < 0) {
            throw new Exception\InvalidArgumentException('$timeout must be between positive (0+)');
        }

        $this->timeout = $timeout;
        $this->onConfigChanged();
    }
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;
    }