redisSetContext: redisSetContext

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/controlCMD.R

Description

Get or set the current active Redis connection environment.

Usage

1
2

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

redisGetContext redisConnect

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## 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 documentation built on May 2, 2019, 2:02 p.m.