Description Usage Arguments Value Author(s) Examples
redis.connect
creates a new connection to a Redis database and
returns the handle.
redis.clone
clones an existing connection by creating a new
connection to the same Redis server using exactly the same settings
as the supplied connection. Optionally, the database can be changed
if db
is set.
redis.close
closes a Redis database connection.
1 2 3 4 5 | redis.connect(host = "localhost", port = 6379L, timeout = 30,
reconnect = FALSE, retry = FALSE, db = getOption("redis.default.db", 0L),
password = NULL)
redis.clone(rc, db = NA)
redis.close(rc)
|
host |
name of the host to connect to or a path to the socket (if
|
port |
numeric, TCP port to connect to or 0 if a local (unix) socket is to be used instead (not supported on Windows, obviously). |
timeout |
numeric, timeout in seconds for requests (reals are supported for sub-second accuracy) |
reconnect |
logical, if |
retry |
logical, if |
db |
integer, index of the database (keyspace) to use. The index
|
password |
string, password to use for authentication with the
server or |
rc |
Redis connection handle (as returned by |
redis.connect
and redis.clone
: an opaque handle to use
for subsequent operations on the connection (object of the class
redisConnection
)
redis.close
: NULL
(invisibly)
Simon Urbanek
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## try connecting -
c <- tryCatch(redis.connect(),
error = function(e) {
cat("Cannot connect",e$message, " - please start Redis\n")
NULL
})
if (!is.null(c)) { ## go ahead only if Redis is up and we got a connection
print(redis.get(c, "foo"))
print(redis.set(c, "foo", "bar"))
print(redis.get(c, "foo"))
redis.rm(c, "foo")
redis.close(c)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.