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
6f078746
Commit
6f078746
authored
May 07, 2010
by
Pieter Noordhuis
Browse files
extract preloading of multiple keys according to the command prototype to a separate function
parent
f3b52411
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
6f078746
...
...
@@ -9548,6 +9548,19 @@ static int waitForSwappedKey(redisClient *c, robj *key) {
return
1
;
}
/* Preload keys for any command with first, last and step values for
* the command keys prototype, as defined in the command table. */
static
void
waitForMultipleSwappedKeys
(
redisClient
*
c
,
struct
redisCommand
*
cmd
,
int
argc
,
robj
**
argv
)
{
int
j
,
last
;
if
(
cmd
->
vm_firstkey
==
0
)
return
;
last
=
cmd
->
vm_lastkey
;
if
(
last
<
0
)
last
=
argc
+
last
;
for
(
j
=
cmd
->
vm_firstkey
;
j
<=
last
;
j
+=
cmd
->
vm_keystep
)
{
redisAssert
(
j
<
argc
);
waitForSwappedKey
(
c
,
argv
[
j
]);
}
}
/* Preload keys needed for the ZUNION and ZINTER commands. */
static
void
zunionInterBlockClientOnSwappedKeys
(
redisClient
*
c
)
{
int
i
,
num
;
...
...
@@ -9568,16 +9581,10 @@ static void zunionInterBlockClientOnSwappedKeys(redisClient *c) {
* Return 1 if the client is marked as blocked, 0 if the client can
* continue as the keys it is going to access appear to be in memory. */
static
int
blockClientOnSwappedKeys
(
struct
redisCommand
*
cmd
,
redisClient
*
c
)
{
int
j
,
last
;
if
(
cmd
->
vm_preload_proc
!=
NULL
)
{
cmd
->
vm_preload_proc
(
c
);
}
else
{
if
(
cmd
->
vm_firstkey
==
0
)
return
0
;
last
=
cmd
->
vm_lastkey
;
if
(
last
<
0
)
last
=
c
->
argc
+
last
;
for
(
j
=
cmd
->
vm_firstkey
;
j
<=
last
;
j
+=
cmd
->
vm_keystep
)
waitForSwappedKey
(
c
,
c
->
argv
[
j
]);
waitForMultipleSwappedKeys
(
c
,
cmd
,
c
->
argc
,
c
->
argv
);
}
/* If the client was blocked for at least one key, mark it as blocked. */
...
...
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