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
00cf82c0
Commit
00cf82c0
authored
Oct 15, 2010
by
Pieter Noordhuis
Browse files
Change tcl client to only use the multibulk protocol
parent
cd8788f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/support/redis.tcl
View file @
00cf82c0
...
@@ -36,25 +36,6 @@ array set ::redis::deferred {}
...
@@ -36,25 +36,6 @@ array set ::redis::deferred {}
array set ::redis::callback
{}
array set ::redis::callback
{}
array set ::redis::state
{}
;
# State in non-blocking reply reading
array set ::redis::state
{}
;
# State in non-blocking reply reading
array set ::redis::statestack
{}
;
# Stack of states, for nested mbulks
array set ::redis::statestack
{}
;
# Stack of states, for nested mbulks
array set ::redis::bulkarg
{}
array set ::redis::multibulkarg
{}
# Flag commands requiring last argument as a bulk write operation
foreach redis_bulk_cmd
{
set setnx rpush lpush rpushx lpushx linsert lset lrem sadd srem sismember echo getset smove zadd zrem zscore zincrby append zrank zrevrank hget hdel hexists setex publish
}
{
set ::redis::bulkarg
(
$redis
_bulk_cmd
)
{}
}
# Flag commands requiring last argument as a bulk write operation
foreach redis_multibulk_cmd
{
mset msetnx hset hsetnx hmset hmget
}
{
set ::redis::multibulkarg
(
$redis
_multibulk_cmd
)
{}
}
unset redis_bulk_cmd
unset redis_multibulk_cmd
proc redis
{{
server 127.0.0.1
}
{
port 6379
}
{
defer 0
}}
{
proc redis
{{
server 127.0.0.1
}
{
port 6379
}
{
defer 0
}}
{
set fd
[
socket $server $port
]
set fd
[
socket $server $port
]
...
@@ -79,25 +60,14 @@ proc ::redis::__dispatch__ {id method args} {
...
@@ -79,25 +60,14 @@ proc ::redis::__dispatch__ {id method args} {
set args
[
lrange $args 0 end-1
]
set args
[
lrange $args 0 end-1
]
}
}
if
{[
info command ::redis::__method__$method
]
eq
{}}
{
if
{[
info command ::redis::__method__$method
]
eq
{}}
{
if
{[
info exists ::redis::bulkarg
(
$method
)]}
{
set cmd
"*
[
expr
{[
llength $args
]
+1
}]
\r\n
"
set cmd
"
$method
"
append cmd
"
$
[
string length $method
]
\r\n
$method
\r\n
"
append cmd
[
join
[
lrange $args 0 end-1
]]
foreach a $args
{
append cmd
"
[
string length
[
lindex $args end
]]
\r\n
"
append cmd
"
$
[
string length $a
]
\r\n
$a
\r\n
"
append cmd
[
lindex $args end
]
::redis::redis_writenl $fd $cmd
}
elseif
{[
info exists ::redis::multibulkarg
(
$method
)]}
{
set cmd
"*
[
expr
{[
llength $args
]
+1
}]
\r\n
"
append cmd
"
$
[
string length $method
]
\r\n
$method
\r\n
"
foreach a $args
{
append cmd
"
$
[
string length $a
]
\r\n
$a
\r\n
"
}
::redis::redis_write $fd $cmd
flush $fd
}
else
{
set cmd
"
$method
"
append cmd
[
join $args
]
::redis::redis_writenl $fd $cmd
}
}
::redis::redis_write $fd $cmd
flush $fd
if
{
!$deferred
}
{
if
{
!$deferred
}
{
if
{
$blocking
}
{
if
{
$blocking
}
{
::redis::redis_read_reply $fd
::redis::redis_read_reply $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