/man/redisSetContext.Rd

http://github.com/bwlewis/rredis · Unknown · 62 lines · 58 code · 4 blank · 0 comment · 0 complexity · 28aea4679b220181e6e39d3cfa1c758a MD5 · raw file

  1. \name{redisSetContext}
  2. \alias{redisSetContext}
  3. \alias{redisGetContext}
  4. \title{redisSetContext}
  5. \description{Get or set the current active Redis connection environment.}
  6. \usage{
  7. redisSetContext( e = NULL)
  8. redisGetContext()
  9. }
  10. \arguments{
  11. \item{e}{
  12. An environment representing the new Redis server connection context
  13. returned by \code{rediscConnect(returnRef=TRUE)}. The default value of NULL
  14. sets the context to the most recently established connection.
  15. }
  16. }
  17. \details{
  18. The rredis package stores information associated with a connection to
  19. a Redis server in an environment. The \code{redisSetContext} and
  20. \code{redisSetContext} functions help manage simultaneous
  21. connection to multiple Redis servers.
  22. The \code{redisSetContext} function returns an environment representing
  23. the current active Redis connection. If there is no current active Redis
  24. connection, an environment is still returned, but without connection
  25. information.
  26. The \code{redisSetContext} function replaces the current active environment.
  27. Any number of simultaneous connections to multiple Redis servers may be managed
  28. in this manner.
  29. }
  30. \value{
  31. NULL is invisibly returned.
  32. }
  33. \author{
  34. B. W. Lewis
  35. }
  36. \seealso{
  37. \code{\link{redisGetContext}}
  38. \code{\link{redisConnect}}
  39. }
  40. \examples{
  41. \dontrun{
  42. # Open a connection to a Redis server on HOST1 and store its context:
  43. HOST1 <- redisConnect(host='HOST1', returnRef=TRUE)
  44. print(redisInfo())
  45. # Initiate a new Redis context:
  46. HOST2 <- redisConnect(host='HOST2', returnRef=TRUE)
  47. # The connection to HOST2 is now active:
  48. print(redisInfo())
  49. # We may now switch back and forth between the two active connections:
  50. redisSetContext(HOST1)
  51. print(redisInfo())
  52. redisSetContext(HOST2)
  53. print(redisInfo())
  54. redisClose()
  55. redisSetContext(HOST1)
  56. redisClose()
  57. }
  58. }