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
37bf3e18
Commit
37bf3e18
authored
Oct 31, 2019
by
antirez
Browse files
Modules: block ok keys: improve example.
parent
66f55bc5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/modules/hellotype.c
View file @
37bf3e18
...
...
@@ -244,12 +244,20 @@ int HelloTypeBRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
return
RedisModule_ReplyWithError
(
ctx
,
REDISMODULE_ERRORMSG_WRONGTYPE
);
}
/* Parse the timeout before even trying to serve the client synchronously,
* so that we always fail ASAP on syntax errors. */
long
long
timeout
;
if
(
RedisModule_StringToLongLong
(
argv
[
4
],
&
timeout
)
!=
REDISMODULE_OK
)
{
return
RedisModule_ReplyWithError
(
ctx
,
"ERR invalid timeout parameter"
);
}
/* Can we serve the reply synchronously? */
if
(
type
!=
REDISMODULE_KEYTYPE_EMPTY
)
{
return
HelloTypeRange_RedisCommand
(
ctx
,
argv
,
argc
-
1
);
}
/* Otherwise let's block on the key. */
void
*
privdata
=
RedisModule_Alloc
(
100
);
RedisModule_BlockClientOnKeys
(
ctx
,
HelloBlock_Reply
,
HelloBlock_Timeout
,
HelloBlock_FreeData
,
timeout
,
argv
+
1
,
1
,
privdata
);
return
REDISMODULE_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