Last active
August 29, 2015 14:22
-
-
Save pedro/453caba8edb238182a98 to your computer and use it in GitHub Desktop.
R + Redis on Heroku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# used by the R buildpack to install dependencies: | |
# https://github.com/virtualstaticvoid/heroku-buildpack-r | |
install.packages("rredis", dependencies = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("rredis") | |
redis_url <- Sys.getenv("REDIS_URL") | |
host <- gsub("redis://.*@(.+):.*", "\\1", redis_url) | |
pass <- gsub("redis://.*:(.+)@.*", "\\1", redis_url) | |
port <- as.integer(gsub(".*:(.*)$", "\\1", redis_url)) | |
redisConnect(host=host, port=port, password=pass) | |
# set/get stuff: | |
redisSet("foo", "bar") | |
print(redisGet("foo")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment