Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

redisSetContext

redisSetContext


Description

Get or set the current active Redis connection environment.

Usage

redisSetContext( e = NULL)
redisGetContext()

Arguments

e

An environment representing the new Redis server connection context returned by rediscConnect(returnRef=TRUE). The default value of NULL sets the context to the most recently established connection.

Details

The rredis package stores information associated with a connection to a Redis server in an environment. The redisSetContext and redisSetContext functions help manage simultaneous connection to multiple Redis servers.

The redisSetContext function returns an environment representing the current active Redis connection. If there is no current active Redis connection, an environment is still returned, but without connection information.

The redisSetContext function replaces the current active environment. Any number of simultaneous connections to multiple Redis servers may be managed in this manner.

Value

NULL is invisibly returned.

Author(s)

B. W. Lewis

See Also

Examples

## Not run: 
# Open a connection to a Redis server on HOST1 and store its context:
HOST1 <- redisConnect(host='HOST1', returnRef=TRUE)
print(redisInfo())

# Initiate a new Redis context:
HOST2 <- redisConnect(host='HOST2', returnRef=TRUE)
# The connection to HOST2 is now active:
print(redisInfo())

# We may now switch back and forth between the two active connections:
redisSetContext(HOST1)
print(redisInfo())
redisSetContext(HOST2)
print(redisInfo())
redisClose()
redisSetContext(HOST1)
redisClose()

## End(Not run)

rredis

"Redis" Key/Value Database Client

v1.7.0
Apache License (>= 2.0)
Authors
B. W. Lewis
Initial release
2015-07-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.