Rhiredis is a wrapper of hiredis, which is a minimalistic C client library for the Redis database.
Rhiredis is much faster than rredis on CRAN. However, it internally converts every objects to character
and send them to redis server. The user could still save R objects into redis server with serialize
and base64enc::base64encode
. Please see the benchmark for example.
git clone https://github.com/wush978/Rhiredis.git
cd Rhiredis
git submodule init
git submodule update --recursive
R CMD INSTALL .
library(Rhiredis) con <- redisConnect() redisSET("a", "b") # "OK" redisGET("a")
The name pattern of functions is redis<Command name>
. Please read http://redis.io/commands for more details about commands of redis.
The following example compares the time of inserting strings to redis server between Rhiredis
and rredis
.
suppressPackageStartupMessages(library(Rhiredis)) suppressPackageStartupMessages(library(base64enc)) suppressPackageStartupMessages(library(rredis)) suppressPackageStartupMessages(library(rbenchmark)) con <- Rhiredis::redisConnect() rredis::redisConnect() benchmark( Rhiredis::redisSET("a1", "b1"), rredis::redisSet("a2", "b2") ) Rhiredis::redisGET("a1") rredis::redisGet("a2")
The following example compares the time of inserting R object into redis server between Rhiredis
and rredis
.
suppressPackageStartupMessages(library(Rhiredis)) suppressPackageStartupMessages(library(base64enc)) suppressPackageStartupMessages(library(rredis)) suppressPackageStartupMessages(library(rbenchmark)) con <- Rhiredis::redisConnect() rredis::redisConnect() benchmark( Rhiredis::redisSET("a1", base64encode(serialize(iris, NULL))), rredis::redisSet("a2", iris) ) all.equal(unserialize(base64decode(Rhiredis::redisGET("a1"))), iris) all.equal(rredis::redisGet("a2"), iris)
GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.