<div dir="ltr">Thanks for your suggestion, Dirk.<div><br></div><div>I'll try to rewrite Rhiredis based on your approach and provide a similar rredis interface. If everything is good, I'll try to make it on CRAN if it is possible.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/7/24 Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Hi Wush,<br>
<br>
After some more cleanup and consolidation, the package is now down to this:<br>
<br>
edd@max:~/git/rhiredis$ tree .<br>
.<br>
├── demo<br>
│ ├── 00Index<br>
│ └── simpleRedisClient.R<br>
├── DESCRIPTION<br>
├── LICENSE<br>
├── man<br>
│ └── rhiredis.Rd<br>
├── NAMESPACE<br>
├── R<br>
│ └── redis.R<br>
├── README.md<br>
└── src<br>
├── Makevars<br>
└── Redis.cpp<br>
<br>
4 directories, 10 files<br>
edd@max:~/git/rhiredis$<br>
<br>
One C++ file declaring a simple class, and the Rcpp modules declaration, all<br>
in about sixty lines -- see details at<br>
<a href="https://github.com/eddelbuettel/rhiredis/blob/master/src/Redis.cpp" target="_blank">https://github.com/eddelbuettel/rhiredis/blob/master/src/Redis.cpp</a><br>
<br>
The R file is just one line ensuring the module gets loaded.<br>
<br>
The demo/ script show how to use it:<br>
<br>
edd@max:~/git/rhiredis$ cat demo/simpleRedisClient.R<br>
#!/usr/bin/Rscript<br>
<br>
suppressMessages(library(rhiredis))<br>
print(Redis) # prints the Module's docstrings<br>
<br>
redis <- new(Redis)<br>
redis$exec("PING") # simple PING -> PONG test<br>
redis$exec("PING")<br>
<br>
redis2 <- new(Redis, "127.0.0.1", 6379) # create 2nd instance<br>
redis2$exec("SET testchannel 42") # write some data<br>
redis2$exec("GET testchannel") # retrieve<br>
<br>
You can use any Redis command just by concatenating strings, that should also<br>
work for serializing arbitrary R objects into (raw) strings and back. More<br>
user-level work could be done here. My main focus was to provide the simple<br>
C++ class wrapping everyhing --- without any explicit pointers, smart or<br>
old-fashioned and not one new/delete.<br>
<br>
The C++ file is simple too at just sixty line, see<br>
<br>
<br>
Hope this helps, and thanks for suggesting the Redis wrapper via hiredis.<br>
<br>
Hope this helps, Dirk<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
</div></div></blockquote></div><br></div>