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
5831dd86
Commit
5831dd86
authored
Jun 13, 2016
by
antirez
Browse files
Fix example modules to have the right OnLoad() prototype.
Related to #3293.
parent
a4bce77e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/modules/hellotype.c
View file @
5831dd86
...
@@ -236,7 +236,7 @@ void HelloTypeFree(void *value) {
...
@@ -236,7 +236,7 @@ void HelloTypeFree(void *value) {
/* This function must be present on each Redis module. It is used in order to
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
* register the commands into the Redis server. */
int
RedisModule_OnLoad
(
RedisModuleCtx
*
ctx
)
{
int
RedisModule_OnLoad
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
if
(
RedisModule_Init
(
ctx
,
"hellotype"
,
1
,
REDISMODULE_APIVER_1
)
if
(
RedisModule_Init
(
ctx
,
"hellotype"
,
1
,
REDISMODULE_APIVER_1
)
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
...
...
src/modules/helloworld.c
View file @
5831dd86
...
@@ -539,10 +539,16 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
...
@@ -539,10 +539,16 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
/* This function must be present on each Redis module. It is used in order to
/* This function must be present on each Redis module. It is used in order to
* register the commands into the Redis server. */
* register the commands into the Redis server. */
int
RedisModule_OnLoad
(
RedisModuleCtx
*
ctx
)
{
int
RedisModule_OnLoad
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
if
(
RedisModule_Init
(
ctx
,
"helloworld"
,
1
,
REDISMODULE_APIVER_1
)
if
(
RedisModule_Init
(
ctx
,
"helloworld"
,
1
,
REDISMODULE_APIVER_1
)
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
/* Log the list of parameters passing loading the module. */
for
(
int
j
=
0
;
j
<
argc
;
j
++
)
{
const
char
*
s
=
RedisModule_StringPtrLen
(
argv
[
j
],
NULL
);
printf
(
"Module loaded with ARGV[%d] = %s
\n
"
,
j
,
s
);
}
if
(
RedisModule_CreateCommand
(
ctx
,
"hello.simple"
,
if
(
RedisModule_CreateCommand
(
ctx
,
"hello.simple"
,
HelloSimple_RedisCommand
,
"readonly"
,
0
,
0
,
0
)
==
REDISMODULE_ERR
)
HelloSimple_RedisCommand
,
"readonly"
,
0
,
0
,
0
)
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
return
REDISMODULE_ERR
;
...
...
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