Skip to content

Instantly share code, notes, and snippets.

@pedro
Last active August 29, 2015 14:22
Show Gist options
  • Save pedro/453caba8edb238182a98 to your computer and use it in GitHub Desktop.
Save pedro/453caba8edb238182a98 to your computer and use it in GitHub Desktop.
R + Redis on Heroku
# used by the R buildpack to install dependencies:
# https://github.com/virtualstaticvoid/heroku-buildpack-r
install.packages("rredis", dependencies = TRUE)
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