Create a set of valid Redis configuration options.
Usage
redis_config(..., config = list(...))
Details
Valid arguments here are:
url
: The URL for the Redis server. See examples. (default: Look up environment variableREDIS_URL
orNULL
).host
: The hostname of the Redis server. (default: `127.0.0.1).port
: The port of the Redis server. (default: 6379).path
: The path for a Unix socket if connecting that way.password
: The Redis password (for use withAUTH
). This will be stored in plain text as part of the Redis object. (default:NULL
).db
: The Redis database number to use (for use withSELECT
. Do not use in a redis clustering context. (default:NULL
; i.e., don't switch).timeout
: The maximum number of milliseconds to wait for the connection to be established. (default:NULL
; i.e. wait forever).
The way that configuration options are resolved follows the design for redis-rb very closely.
First, look up (and parse if found) the
REDIS_URL
environment variable and override defaults with that.Any arguments given (
host
,port
,password
,db
) override values inferred from the url or defaults.If
path
is given, that overrides thehost
/port
settings and a socket connection will be used.
Examples
# default config:
redis_config()
#> Redis configuration:
#> - url: redis://127.0.0.1:6379
#> - scheme: redis
#> - host: 127.0.0.1
#> - port: 6379
#> - path:
#> - password:
#> - db:
#> - timeout:
# set values
redis_config(host = "myhost")
#> Redis configuration:
#> - url: redis://myhost:6379
#> - scheme: redis
#> - host: myhost
#> - port: 6379
#> - path:
#> - password:
#> - db:
#> - timeout:
# url settings:
redis_config(url = "redis://:p4ssw0rd@myhost:32000/2")
#> Redis configuration:
#> - url: redis://:p4ssw0rd@myhost:32000/2
#> - scheme: redis
#> - host: myhost
#> - port: 32000
#> - path:
#> - password: p4ssw0rd
#> - db: 2
#> - timeout:
# override url settings:
redis_config(url = "redis://myhost:32000", port = 31000)
#> Redis configuration:
#> - url: redis://myhost:32000
#> - scheme: redis
#> - host: myhost
#> - port: 31000
#> - path:
#> - password:
#> - db:
#> - timeout:
redis_config(url = "redis://myhost:32000", path = "/tmp/redis.conf")
#> Redis configuration:
#> - url: redis://myhost:32000
#> - scheme: unix
#> - host:
#> - port:
#> - path: /tmp/redis.conf
#> - password:
#> - db:
#> - timeout: