public function factory()
    {
        $redis = new \Redis();
        $host = $this->getConfig()->getValue(self::CONFIG_HOST);
        $port = $this->getConfig()->getValue(self::CONFIG_PORT);
        $timeout = $this->getConfig()->getValue(self::CONFIG_TIMEOUT);

        if ($this->getConfig()->getValueFlag(self::CONFIG_PERSISTENT)) {
            $redis->pconnect($host, $port, $timeout);
        } else {
            $redis->connect($host, $port, $timeout);
        }

        if ($this->getConfig()->hasValue(self::CONFIG_DATABASE)) {
            $redis->select($this->getConfig()->getValue(self::CONFIG_DATABASE));
        }

        return $redis;
    }