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
005c932f
Commit
005c932f
authored
Apr 12, 2018
by
antirez
Browse files
Modules API: fix timer example.
parent
4e536240
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/modules/hellotimer.c
View file @
005c932f
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
* POSSIBILITY OF SUCH DAMAGE.
*/
*/
#define REDISMODULE_EXPERIMENTAL_API
#include "../redismodule.h"
#include "../redismodule.h"
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
...
@@ -41,6 +42,7 @@
...
@@ -41,6 +42,7 @@
/* Timer callback. */
/* Timer callback. */
void
timerHandler
(
RedisModuleCtx
*
ctx
,
void
*
data
)
{
void
timerHandler
(
RedisModuleCtx
*
ctx
,
void
*
data
)
{
REDISMODULE_NOT_USED
(
ctx
);
printf
(
"Fired %s!
\n
"
,
data
);
printf
(
"Fired %s!
\n
"
,
data
);
RedisModule_Free
(
data
);
RedisModule_Free
(
data
);
}
}
...
@@ -55,6 +57,7 @@ int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
...
@@ -55,6 +57,7 @@ int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
char
*
buf
=
RedisModule_Alloc
(
256
);
char
*
buf
=
RedisModule_Alloc
(
256
);
snprintf
(
buf
,
256
,
"After %d"
,
delay
);
snprintf
(
buf
,
256
,
"After %d"
,
delay
);
RedisModuleTimerID
tid
=
RedisModule_CreateTimer
(
ctx
,
delay
,
timerHandler
,
buf
);
RedisModuleTimerID
tid
=
RedisModule_CreateTimer
(
ctx
,
delay
,
timerHandler
,
buf
);
REDISMODULE_NOT_USED
(
tid
);
}
}
return
RedisModule_ReplyWithSimpleString
(
ctx
,
"OK"
);
return
RedisModule_ReplyWithSimpleString
(
ctx
,
"OK"
);
}
}
...
...
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