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
5b19bd72
Commit
5b19bd72
authored
Mar 22, 2009
by
antirez
Browse files
MGET tests added
parent
e255235c
Changes
1
Hide whitespace changes
Inline
Side-by-side
test-redis.tcl
View file @
5b19bd72
...
@@ -553,6 +553,23 @@ proc main {server port} {
...
@@ -553,6 +553,23 @@ proc main {server port} {
list
[
redis_lrange $fd mylist 0 -1
]
$res
list
[
redis_lrange $fd mylist 0 -1
]
$res
}
{{
foo bar foobar foobared zap test
}
2
}
}
{{
foo bar foobar foobared zap test
}
2
}
test
{
MGET
}
{
redis_flushall $fd
redis_set $fd foo BAR
redis_set $fd bar FOO
redis_mget $fd foo bar
}
{
BAR FOO
}
test
{
MGET against non existing key
}
{
redis_mget $fd foo baazz bar
}
{
BAR
{}
FOO
}
test
{
MGET against non-string key
}
{
redis_sadd $fd myset ciao
redis_sadd $fd myset bau
redis_mget $fd foo baazz bar myset
}
{
BAR
{}
FOO
{}}
# Leave the user with a clean DB before to exit
# Leave the user with a clean DB before to exit
test
{
FLUSHALL
}
{
test
{
FLUSHALL
}
{
redis_flushall $fd
redis_flushall $fd
...
@@ -589,9 +606,10 @@ proc redis_readnl {fd len} {
...
@@ -589,9 +606,10 @@ proc redis_readnl {fd len} {
return $buf
return $buf
}
}
proc redis_bulk_read fd
{
proc redis_bulk_read
{
fd
{
multi 0
}}
{
set count
[
redis_read_integer $fd
]
set count
[
redis_read_integer $fd
]
if
{
$count
eq
{
nil
}}
return
{}
if
{
$count
eq
{
nil
}}
return
{}
if
{
$multi
&& $count == -1
}
return
{}
set len
[
expr
{
abs
(
$count
)}]
set len
[
expr
{
abs
(
$count
)}]
set buf
[
redis_readnl $fd $len
]
set buf
[
redis_readnl $fd $len
]
if
{
$count
< 0
}
{
return
"***ERROR***
$buf
"
}
if
{
$count
< 0
}
{
return
"***ERROR***
$buf
"
}
...
@@ -608,7 +626,7 @@ proc redis_multi_bulk_read fd {
...
@@ -608,7 +626,7 @@ proc redis_multi_bulk_read fd {
}
}
set l
{}
set l
{}
for
{
set i 0
}
{
$i
< $count
}
{
incr i
}
{
for
{
set i 0
}
{
$i
< $count
}
{
incr i
}
{
lappend l
[
redis_bulk_read $fd
]
lappend l
[
redis_bulk_read $fd
1
]
}
}
return $l
return $l
}
}
...
@@ -710,6 +728,11 @@ proc redis_lrange {fd key first last} {
...
@@ -710,6 +728,11 @@ proc redis_lrange {fd key first last} {
redis_multi_bulk_read $fd
redis_multi_bulk_read $fd
}
}
proc redis_mget
{
fd args
}
{
redis_writenl $fd
"mget
[
join $args
]
"
redis_multi_bulk_read $fd
}
proc redis_sort
{
fd key
{
params
{}}}
{
proc redis_sort
{
fd key
{
params
{}}}
{
redis_writenl $fd
"sort
$key
$params
"
redis_writenl $fd
"sort
$key
$params
"
redis_multi_bulk_read $fd
redis_multi_bulk_read $fd
...
...
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