R backend

library(devtools)
library(microbenchmark)

Blocking

dev_mode(TRUE)
## Dev mode: ON
install_git(".", branch = "master")
## Preparing installation of . using the Git-URL: .
## Installing rredis
## '/usr/lib/R/bin/R' --vanilla CMD INSTALL \
## '/tmp/RtmpjJsyjw/file14e746718c87' --library='/home/wush/R-dev' \
## --with-keep.source
## ```

```r
library(rredis)
redisConnect()
redisSetBlocking(TRUE)
microbenchmark(unit = "us", redisSet("a", 123))
## Unit: microseconds
##                expr   min    lq median    uq   max neval
##  redisSet("a", 123) 39285 39809  39995 40096 40630   100
microbenchmark(unit = "us", a1 <- redisGet("a"))
## Unit: microseconds
##                 expr   min    lq median    uq   max neval
##  a1 <- redisGet("a") 39266 39861  40001 40158 43608   100
redisClose()

Non-blocking

redisConnect()
redisSetBlocking(FALSE)
microbenchmark(unit = "us", redisSet("a", 123))
## Unit: microseconds
##                expr   min    lq median    uq  max neval
##  redisSet("a", 123) 521.9 529.4  536.6 557.8 2119   100
microbenchmark(unit = "us", redisGet("a"))
## Unit: microseconds
##           expr   min  lq median    uq   max neval
##  redisGet("a") 396.4 401  420.2 449.4 655.6   100
microbenchmark(unit = "us", a2 <- redisGetResponse())
## Unit: microseconds
##                      expr   min    lq median    uq   max neval
##  a2 <- redisGetResponse() 6.566 6.776  6.985 7.125 16757   100
redisClose()
dev_mode(FALSE)
## Dev mode: OFF

hiredis backend

Blocking

dev_mode(TRUE)
## Dev mode: ON
install_git(".", branch = "hiredis")
## Preparing installation of . using the Git-URL: .
## Installing rredis
## '/usr/lib/R/bin/R' --vanilla CMD INSTALL \
## '/tmp/RtmpjJsyjw/file14e72dce37ce' --library='/home/wush/R-dev' \
## --with-keep.source
## ```

Reloading installed rredis


```r
library(rredis)
redisConnect()
redisSetBlocking(TRUE)
microbenchmark(unit = "us", redisSet("a", 123))
## Unit: microseconds
##                expr   min    lq median    uq    max neval
##  redisSet("a", 123) 523.6 540.2  550.6 566.9 101476   100
microbenchmark(unit = "us", b1 <- redisGet("a"))
## Unit: microseconds
##                 expr   min    lq median    uq   max neval
##  b1 <- redisGet("a") 241.7 244.7  245.8 247.7 656.6   100
redisClose()

Non-blocking

redisConnect()
redisSetBlocking(FALSE)
microbenchmark(unit = "us", redisSet("a", 123))
## Unit: microseconds
##                expr   min    lq median  uq   max neval
##  redisSet("a", 123) 200.9 204.2  206.2 214 553.8   100
microbenchmark(unit = "us", redisGet("a"))
## Unit: microseconds
##           expr   min    lq median    uq   max neval
##  redisGet("a") 172.6 174.6  175.6 180.2 374.7   100
microbenchmark(unit = "us", b2 <- redisGetResponse())
## Unit: microseconds
##                      expr   min    lq median    uq   max neval
##  b2 <- redisGetResponse() 7.334 7.613  7.753 8.033 53019   100
redisClose()
dev_mode(FALSE)
## Dev mode: OFF

Validation

all.equal(a1, b1)
## [1] TRUE
all.equal(a2, b2)
## [1] TRUE