Write data for key into cache.

@param string $key Identifier for the data
@param mixed $value Data to be cached
@return bool True if the data was successfully cached, false on failure
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);
    }
954963
public function set($key, $value)
    {
        $array = &$this->data;
        $keys = explode(self::SEPERATOR, $key);
        $i = 1;
        foreach ($keys as $item) {
            if (is_array($array) && array_key_exists($item, $array) && !is_array($array[$item]) && $i !== count($keys)) {
                return false;
            }
            $array = &$array[$item];
            $i++;
        }
        $array = $value;
        $this->save();
        return true;
    }
730345
public function store($key, $value)
    {

        if (!is_array($value)) {
            $value = array($key => $value);
        } else {
            $value = array_dot($value);

            foreach ($value as $k => $v) {
                $value[$key . '.' . $k] = $v;
                unset($value[$k]);
            }
        }

        foreach ($value as $k => $v) {
            $this->_store($k, $v);
        }

    }
207310
public function cacheValue(string $key, $value)
    {
        if (!Config::get('activateDbCache')) {
            return false;
        }

        if ($this->getValue($key)) {
            throw new \Exception('Duplicate entry in tl_db_cache for key '.$key);
        }

        $now = time();

        $this->database->prepare('INSERT INTO tl_db_cache (tstamp, expiration, cacheKey, cacheValue) VALUES (?, ?, ?, ?)')->execute(
            $now,
            $now + $this->container->get('huh.utils.date')->getTimePeriodInSeconds(
                StringUtil::deserialize(Config::get('dbCacheMaxTime'), true)
            ),
            $key,
            $value
        );

        return true;
    }
788104
public static function set($key, $value = '')
    {
        empty(self::$prefix) && self::$prefix = Config::get('session_prefix');
        if (!is_array($key)) {
            $_SESSION[self::$prefix . $key] = $value;
        } else {
            foreach ($key as $k => $v) {
                $_SESSION[self::$prefix . $k] = $v;
            }
        }
        return true;
    }
942812
public static function hasKeyAndValue(string $key, $value): bool
    {
        static::startSessionIfNotHasStarted();

        return \array_key_exists($key, $_SESSION) && $_SESSION[$key] === $value;
    }
1067876
protected function writeOption(string $key, $value): bool
    {
        return $value === get_option($this->prefix . $key)
               || update_option($this->prefix . $key, $value);
    }
839478
public function writeElement($key, $value)
    {
        if (is_array($value)) {
            $this->iterateArray($key, $value);
        } else {
            $value = \Genesis\Utils\Common::booleanToString($value);

            $this->context->writeElement($key, $value);
        }
    }
977343
protected function cache($key, $value = null)
    {
        if (is_null($value) && $this->cacheHas($key)) {
            array_forget($this->cache, $key);
            return null;
        }

        if (is_null($value)) {
            return array_get($this->cache, $key, false);
        }

        if (! is_bool($value)) {
            $value  =   false;
        }

        array_set($this->cache, $key, $value);

        return $value;
    }
333759
public function set($key, $value)
    {
        $position = $this->getPosition($key);
        if (false !== $position) {
            $this->file->update($position, $key, $value);
            $this->rebuildIndex();
        } else {
            $pos = $this->file->insert($key, $value);
            $this->index->set($key, $pos);
        }

        return true;
    }
1092184
public static function set($key, $value) {
		$memcache = self::connect();
		$config = \Skeleton\Object\Config::$cache_handler_config;
		$memcache->add($key, $value, false, $config['expire']);
	}
1319999
public function write($key, $value)
    {
        $key = $this->_key($key);
        $duration = $this->_config['duration'];

        return apcu_store($key, $value, $duration);
    }
847334
public function store($key = '', $value = array(), $lock = true)
  {
    if ($key == '') {
      $this->fault('[Error] Cannot store data without a key. Key is "' . $key . '".');
    }

    if (!$this->has_key($key)) {
      $this->create($key, $lock);
      $this->store_data($key, $value);
    } else {
      if (!$this->is_locked($key)) {
        $this->store_data($key, $value);
      } else {
        $this->fault('[Error] Cannot store data with a registered key that is locked.');
      }
    }
  }
1355718
public function set($key, $value)
    {
        $setting = SettingModel::create(
            [
                'key' => $key,
                'value' => $value,
            ]
        );

        return $setting ? $value : false;
    }
1278595
public function replace($key, $value)
    {
        if ($this->has($key)) {
            $this[$key] = $value;

            return true;
        }

        return false;
    }
1074948
public function write($key, $value, $ttl = 0)
    {
        $this->redis->set($this->prefix . $key, is_numeric($value) ? $value : serialize($value));
        if ($ttl != 0) {
            $this->redis->expire($this->prefix . $key, $ttl);
        }
        return true;
    }
191998
public function write($key, $value, $expire = null) 
    {
        if (!$this->enabled) {
            return ;
        }

        if ($expire === null) {
            $expire = $this->expire;
        }
        
        $data = [
            'time'   => time(),
            'expire' => time() + $expire,
            'value'  => $value,
        ];
    
        $this->stats['execTimes'] ++;
        $this->stats['writeTimes'] ++;            
        $this->stats['writeSize'] += strlen(var_export($value, true))/1024;
        $this->temp[$key] = $data;
        
        try {
            $this->waitUnlock($key);
            $this->lock($key);
            $this->store($key, $data);
            $this->unlock($key);
        } catch (\wf\cache\Exception $e) {
            $this->unlock($key);
            throw $e;
        }
    }