write data to redis store

@param $key
@param $vars
@return bool
356295
public function write($key, $vars)
    {
        $data = serialize(array('changed' => time(), 'ip' => $this->ip, 'vars' => $vars));

        return $this->redis->setex($key, $this->lifetime + 60, $data);
    }
899623
public function sunionstore($key,$keys){
        try {
            return $this->redis->sunionstore($key, $keys);
        } catch (\RedisException $e) {
            die("Error!: " . $e->getMessage() . "<br/>");
        }
    }
569664
public function populate(array $vars)
	{
		foreach ($vars as $key => $value)
		{
			if (false === getenv($key))
			{
				$_ENV[$key] = $value;
				$_SERVER[$key] = $value;
				putenv("{$key}={$value}");
			}
		}
	}
357192
final public function del($keys) {
		$res = $this->connection->del($keys);
		$res_log = $res ? 'ok' : 'fail';
		$res_keys = $keys;
		if (!is_array($keys))
			$keys = func_get_args();
		$res_keys = json_encode($keys);
		self::$logger->info(sprintf(
			"Redis: delete %s: '%s'.",
			$res_log, $res_keys));
		return $res;
	}
187420
public function store( $key, $var, $expire = 0 )
    {
        if ( strlen( $key ) > self::MAX_KEY_LENGTH )
        {
            throw new ezcCacheInvalidKeyException( $key, 'Length > ' . self::MAX_KEY_LENGTH . '.' );
        }

        // protect our data by wrapping it in an object
        $data = new ezcCacheMemoryVarStruct( $key, $var, $expire );
        $compressed = ( $this->options->compressed === true ) ? MEMCACHE_COMPRESSED : false;
        return $this->memcache->set( $key, $data, $compressed, $expire );
    }
977037
public function write($key, $data)
    {
        $this->_cachedData[$key] = $data;
        Cache::set('model-metadata', $this->_cachedData, Cache::TTL_ONE_MONTH);
    }
6885
public function delete($key)
    {
        $key = $this->_key($key);

        return $this->_Redis->delete($key) > 0;
    }
722425
public function delete(string $key): bool
    {
        Redis::delete(self::PREFIX . $key);
        return parent::delete($key);
    }
777562
public function sremove($key, $member)
    {
        try {
            return $this->redis->sremove($key, $member);
        } catch (\RedisException $e) {
            die("Error!: " . $e->getMessage() . "<br/>");
        }
    }
519305
private function hash($key)
    {
        $serverNum = count($this->conf['server']);
        $success = sprintf('%u', crc32($key)) % $serverNum;

        if (!isset($this->redis[$success]) || !is_object($this->redis[$success])) {
            $instance = new \Redis();

            $connectToRedisFunction = function ($host, $port, $isPersistentConnect) use ($instance) {
                if ($isPersistentConnect) {
                    return $instance->pconnect($host, $port, 1.5);
                } else {
                    return $instance->connect($host, $port, 1.5);
                }
            };

            $isPersistentConnect = !(isset($this->conf['server'][$success]['pconnect']) && $this->conf['server'][$success]['pconnect'] === false);
            $connectResult = $connectToRedisFunction($this->conf['server'][$success]['host'], $this->conf['server'][$success]['port'], $isPersistentConnect);

            $failOver = null;

            if (!$connectResult && !empty($this->conf['back'])) {
                $failOver = $this->conf['back'];
                $isPersistentConnect = !(isset($failOver['pconnect']) && $failOver['pconnect'] === false);
                $connectResult = $connectToRedisFunction($failOver['host'], $failOver['port'], $isPersistentConnect);
            }

            if (!$connectResult && $serverNum > 1) {
                $failOver = $success + 1;
                $failOver >= $serverNum && $failOver = $success - 1;
                $failOver = $this->conf['server'][$failOver];
                $isPersistentConnect = !(isset($failOver['pconnect']) && $failOver['pconnect'] === false);
                $connectResult = $connectToRedisFunction($failOver['host'], $failOver['port'], $isPersistentConnect);
            }

            if (!$connectResult) {
                Plugin::hook('cml.cache_server_down', [$this->conf['server'][$success]]);

                throw new CacheConnectFailException(Lang::get('_CACHE_CONNECT_FAIL_', 'Redis',
                    $this->conf['server'][$success]['host'] . ':' . $this->conf['server'][$success]['port']
                ));
            }

            $password = false;
            if (is_null($failOver)) {
                if (isset($this->conf['server'][$success]['password']) && !empty($this->conf['server'][$success]['password'])) {
                    $password = $this->conf['server'][$success]['password'];
                }

                if ($password && !$instance->auth($password)) {
                    throw new \RuntimeException('redis password error!');
                }

                isset($this->conf['server'][$success]['db']) && $instance->select($this->conf['server'][$success]['db']);
            } else {
                if (isset($failOver['password']) && !empty($failOver['password'])) {
                    $password = $failOver['password'];
                }

                if ($password && !$instance->auth($password)) {
                    throw new \RuntimeException('redis password error!');
                }

                isset($failOver['db']) && $instance->select($failOver['db']);

                Log::emergency('redis server down', ['downServer' => $this->conf['server'][$success], 'failOverTo' => $failOver]);
                Plugin::hook('cml.redis_server_down_fail_over', ['downServer' => $this->conf['server'][$success], 'failOverTo' => $failOver]);
            }

            $instance->setOption(\Redis::OPT_PREFIX, $this->conf['prefix']);
            $this->redis[$success] = $instance;
        }
        return $this->redis[$success];
    }
626895
public function read($key)
    {
        $data = $this->redis->get($this->prefix . $key);
        return $data === null ? false : (is_numeric($data) ? $data : unserialize($data));
    }
1182923
public function write($key, $vars)
    {
        $now = $this->db->now();

        $this->db->query("INSERT INTO {$this->table_name}"
            . " (`sess_id`, `vars`, `ip`, `changed`)"
            . " VALUES (?, ?, ?, $now)",
            $key, base64_encode($vars), (string)$this->ip);

        return true;
    }
403670
final public function expire($key, $ttl) {
		$method = 'setTimeout';
		if ($this->redistype == 'predis')
			$method = 'expire';
		$res = $this->connection->$method($key, $ttl);
		self::$logger->info(sprintf(
			"Redis: expire %s: %s.", $key, $ttl));
		return $res;
	}
1327036
public function set($key, $val, $expire = 0)
    {
        if (!is_numeric($val)) {
            $val = json_encode($val);
        }

        if ($expire) {
            return $this->redis->setex($key, $expire, $val);
        }

        return $this->redis->set($key, $val);
    }
65592
public function update($key, $newvars, $oldvars)
    {
        $now = $this->db->now();
        $ts  = microtime(true);

        // if new and old data are not the same, update data
        // else update expire timestamp only when certain conditions are met
        if ($newvars !== $oldvars) {
            $this->db->query("UPDATE {$this->table_name} "
                . "SET `changed` = $now, `vars` = ? WHERE `sess_id` = ?",
                base64_encode($newvars), $key);
        }
        else if ($ts - $this->changed + $this->time_diff > $this->lifetime / 2) {
            $this->db->query("UPDATE {$this->table_name} SET `changed` = $now"
                . " WHERE `sess_id` = ?", $key);
        }

        return true;
    }
490314
public function spop($key)
    {
        try {
            return $this->redis->spop($key);
        } catch (\RedisException $e) {
            die("Error!: " . $e->getMessage() . "<br/>");
        }
    }
611527
public function setVars($vars)
    {
        // If vars is an array
        if (is_array($vars) && count($vars)) {
            // Iterate and set the var
            foreach ($vars as $key => $value) {
                $this->setVar($key, $value);
            }
        }
        return $this;
    }