Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
5ba9bdec
Commit
5ba9bdec
authored
Jun 13, 2016
by
antirez
Browse files
Modules: document how to pass config params to modules.
Related to #3293.
parent
5831dd86
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/modules/INTRO.md
View file @
5ba9bdec
...
...
@@ -65,7 +65,7 @@ simple module that implements a command that outputs a random number.
return REDISMODULE_OK;
}
int RedisModule_OnLoad(RedisModuleCtx *ctx) {
int RedisModule_OnLoad(RedisModuleCtx *ctx
, RedisModuleString **argv, int argc
) {
if (RedisModule_Init(ctx,"helloworld",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
...
...
@@ -156,6 +156,24 @@ exported.
The module will be able to load into different versions of Redis.
# Passing configuration parameters to Redis modules
When the module is loaded with the
`MODULE LOAD`
command, or using the
`loadmodule`
directive in the
`redis.conf`
file, the user is able to pass
configuration parameters to the module by adding arguments after the module
file name:
loadmodule mymodule.so foo bar 1234
In the above example the strings
`foo`
,
`bar`
and
`123`
will be passed
to the module
`OnLoad()`
function in the
`argv`
argument as an array
of RedisModuleString pointers. The number of arguments passed is into
`argc`
.
The way you can access those strings will be explained in the rest of this
document. Normally the module will store the module configuration parameters
in some
`static`
global variable that can be accessed module wide, so that
the configuration can change the behavior of different commands.
# Working with RedisModuleString objects
The command argument vector
`argv`
passed to module commands, and the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment