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
870274be
Commit
870274be
authored
Oct 13, 2016
by
antirez
Browse files
Example modules: remove warnings about types and not used args.
parent
7dde8bf3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/modules/helloblock.c
View file @
870274be
...
@@ -39,12 +39,16 @@
...
@@ -39,12 +39,16 @@
/* Reply callback for blocking command HELLO.BLOCK */
/* Reply callback for blocking command HELLO.BLOCK */
int
HelloBlock_Reply
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
int
HelloBlock_Reply
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
REDISMODULE_NOT_USED
(
argv
);
REDISMODULE_NOT_USED
(
argc
);
int
*
myint
=
RedisModule_GetBlockedClientPrivateData
(
ctx
);
int
*
myint
=
RedisModule_GetBlockedClientPrivateData
(
ctx
);
return
RedisModule_ReplyWithLongLong
(
ctx
,
*
myint
);
return
RedisModule_ReplyWithLongLong
(
ctx
,
*
myint
);
}
}
/* Timeout callback for blocking command HELLO.BLOCK */
/* Timeout callback for blocking command HELLO.BLOCK */
int
HelloBlock_Timeout
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
int
HelloBlock_Timeout
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
REDISMODULE_NOT_USED
(
argv
);
REDISMODULE_NOT_USED
(
argc
);
return
RedisModule_ReplyWithSimpleString
(
ctx
,
"Request timedout"
);
return
RedisModule_ReplyWithSimpleString
(
ctx
,
"Request timedout"
);
}
}
...
@@ -104,6 +108,9 @@ int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a
...
@@ -104,6 +108,9 @@ int HelloBlock_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int a
/* 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
,
RedisModuleString
**
argv
,
int
argc
)
{
int
RedisModule_OnLoad
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
REDISMODULE_NOT_USED
(
argv
);
REDISMODULE_NOT_USED
(
argc
);
if
(
RedisModule_Init
(
ctx
,
"helloblock"
,
1
,
REDISMODULE_APIVER_1
)
if
(
RedisModule_Init
(
ctx
,
"helloblock"
,
1
,
REDISMODULE_APIVER_1
)
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
==
REDISMODULE_ERR
)
return
REDISMODULE_ERR
;
...
...
src/modules/helloworld.c
View file @
870274be
...
@@ -46,6 +46,8 @@
...
@@ -46,6 +46,8 @@
* fetch the currently selected DB, the other in order to send the client
* fetch the currently selected DB, the other in order to send the client
* an integer reply as response. */
* an integer reply as response. */
int
HelloSimple_RedisCommand
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
int
HelloSimple_RedisCommand
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
REDISMODULE_NOT_USED
(
argv
);
REDISMODULE_NOT_USED
(
argc
);
RedisModule_ReplyWithLongLong
(
ctx
,
RedisModule_GetSelectedDb
(
ctx
));
RedisModule_ReplyWithLongLong
(
ctx
,
RedisModule_GetSelectedDb
(
ctx
));
return
REDISMODULE_OK
;
return
REDISMODULE_OK
;
}
}
...
@@ -237,6 +239,8 @@ int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
...
@@ -237,6 +239,8 @@ int HelloRandArray_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, i
* comments the function implementation). */
* comments the function implementation). */
int
HelloRepl1_RedisCommand
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
int
HelloRepl1_RedisCommand
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
{
REDISMODULE_NOT_USED
(
argv
);
REDISMODULE_NOT_USED
(
argc
);
RedisModuleCallReply
*
reply
;
RedisModuleCallReply
*
reply
;
RedisModule_AutoMemory
(
ctx
);
RedisModule_AutoMemory
(
ctx
);
...
@@ -519,7 +523,7 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
...
@@ -519,7 +523,7 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
/* If the string is already larger than the target len, just return
/* If the string is already larger than the target len, just return
* the string itself. */
* the string itself. */
if
(
strlen
>=
padlen
)
if
(
strlen
>=
(
size_t
)
padlen
)
return
RedisModule_ReplyWithString
(
ctx
,
argv
[
1
]);
return
RedisModule_ReplyWithString
(
ctx
,
argv
[
1
]);
/* Padding must be a single character in this simple implementation. */
/* Padding must be a single character in this simple implementation. */
...
@@ -530,7 +534,7 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
...
@@ -530,7 +534,7 @@ int HelloLeftPad_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
/* Here we use our pool allocator, for our throw-away allocation. */
/* Here we use our pool allocator, for our throw-away allocation. */
padlen
-=
strlen
;
padlen
-=
strlen
;
char
*
buf
=
RedisModule_PoolAlloc
(
ctx
,
padlen
+
strlen
);
char
*
buf
=
RedisModule_PoolAlloc
(
ctx
,
padlen
+
strlen
);
for
(
size_t
j
=
0
;
j
<
padlen
;
j
++
)
buf
[
j
]
=
*
ch
;
for
(
long
long
j
=
0
;
j
<
padlen
;
j
++
)
buf
[
j
]
=
*
ch
;
memcpy
(
buf
+
padlen
,
str
,
strlen
);
memcpy
(
buf
+
padlen
,
str
,
strlen
);
RedisModule_ReplyWithStringBuffer
(
ctx
,
buf
,
padlen
+
strlen
);
RedisModule_ReplyWithStringBuffer
(
ctx
,
buf
,
padlen
+
strlen
);
...
...
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