cpp-redis/cpp_redis

Redis client xrevrange command has an issue with reading n elements from given stream

dhruvkakadiya opened this issue · 0 comments

As per xrevrange documentation, to get number of elements from given stream "COUNT" word needs to be there before actual value which is missing in current code.

Current code:

	client &
	client::xrevrange(const std::string &key, const range_options_t &range_args, const reply_callback_t &reply_callback) {
		std::vector<std::string> cmd = {"XREVRANGE", key, range_args.Start, range_args.Stop};
		if (range_args.Count > 0) {
			cmd.emplace_back(std::to_string(range_args.Count));
		}
		send(cmd, reply_callback);
		return *this;
	}

Fixed code:

	client &
	client::xrevrange(const std::string &key, const range_options_t &range_args, const reply_callback_t &reply_callback) {
		std::vector<std::string> cmd = {"XREVRANGE", key, range_args.Start, range_args.Stop};
		if (range_args.Count > 0) {
			cmd.emplace_back("COUNT");
			cmd.push_back(std::to_string(range_args.Count));
		}
		send(cmd, reply_callback);
		return *this;
	}