// redis "get from list from start to end" -- without R serialization Rcpp::List listRange(std::string key, int start, int end) { // uses binary protocol, see hiredis doc at github redisReply *reply = static_cast<redisReply*>(redisCommand(prc_, "LRANGE %s %d %d", key.c_str(), start, end)); //Rcpp::Rcout << "listRange got type: " << replyTypeToString(reply) << "\n"; checkReplyType(reply, replyArray_t); // ensure we got array unsigned int len = reply->elements; Rcpp::List x(len); for (unsigned int i = 0; i < len; i++) { checkReplyType(reply->element[i], replyString_t); // ensure we got [binary] string int nc = reply->element[i]->len; Rcpp::NumericVector v(nc/szdb); memcpy(v.begin(), reply->element[i]->str, nc); x[i] = v; } freeReplyObject(reply); return(x); }
RedisReply::RedisReply(DBConnector *db, string command, int expectedType) : RedisReply(db, command) { guard([&]{checkReplyType(expectedType);}, command.c_str()); }