Additional publisher function using plain text · eddelbuettel/rcppredis@47f4458 (original) (raw)

Original file line number Diff line number Diff line change
@@ -975,6 +975,14 @@ class Redis {
975 975 return(rep);
976 976 }
977 977
978 +// redis publish as text, no serialization
979 + SEXP publishText(std::string channel, std::string msg) {
980 + redisReply *reply = static_cast<redisReply*>(redisCommandNULLSafe(prc_, "PUBLISH %s %s", channel.c_str(), msg.c_str()));
981 + SEXP rep = extract_reply(reply);
982 +freeReplyObject(reply);
983 +return(rep);
984 + }
985 +
978 986 };
979 987
980 988 RCPP_MODULE(Redis) {
@@ -1046,6 +1054,7 @@ RCPP_MODULE(Redis) {
1046 1054 .method("quit", &Redis::quit, "runs 'QUIT' to close connection")
1047 1055
1048 1056 .method("publish", &Redis::publish, "runs 'PUBLISH channel message', serializes message internally")
1057 + .method("publishText", &Redis::publishText, "runs 'PUBLISH channel message' without serialization of the message")
1049 1058 .method("subscribe", &Redis::subscribe, "runs 'SUBSCRIBE channel(s)', subscribe to one or more channels specified as a character vector")
1050 1059 .method("psubscribe", &Redis::subscribe, "runs 'PSUBSCRIBE channel(s)', subscribe to one or more channel patterns specified as a character vector")
1051 1060 .method("unsubscribe", &Redis::subscribe, "runs 'UNSUBSCRIBE channel(s)', unsubscribe one or more channels specified as a character vector")