# Flag commands requiring last argument as a bulk write operation
foreach redis_multibulk_cmd {
- mset
+ mset msetnx
} {
set ::redis::multibulkarg($redis_multibulk_cmd) {}
}
append cmd [lindex $args end]
::redis::redis_writenl $fd $cmd
} elseif {[info exists ::redis::multibulkarg($method)]} {
- set cmd "*[expr {[llength $args]}+1]\r\n"
+ 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]
*
* If so, the function returns REDIS_OK and *longval is set to the value
* of the number. Otherwise REDIS_ERR is returned */
-static int isStringRepresentableAsLong(char *s, long *longval) {
+static int isStringRepresentableAsLong(sds s, long *longval) {
char buf[32], *endptr;
long value;
int slen;
/* If the number converted back into a string is not identical
* then it's not possible to encode the string as integer */
- if (strlen(buf) != (unsigned)slen || memcmp(buf,s,slen)) return REDIS_ERR;
+ if (sdslen(s) != (unsigned)slen || memcmp(buf,s,slen)) return REDIS_ERR;
if (longval) *longval = value;
return REDIS_OK;
}
format $err
} {ERR*}
+ test {MSET base case} {
+ $r mset x 10 y "foo bar" z "x x x x x x x\n\n\r\n"
+ $r mget x y z
+ } [list 10 {foo bar} "x x x x x x x\n\n\r\n"]
+
+ test {MSET wrong number of args} {
+ catch {$r mset x 10 y "foo bar" z} err
+ format $err
+ } {*wrong number*}
+
+ test {MSETNX with already existent key} {
+ list [$r msetnx x1 xxx y2 yyy x 20] [$r exists x1] [$r exists y2]
+ } {0 0 0}
+
+ test {MSETNX with not existing keys} {
+ list [$r msetnx x1 xxx y2 yyy] [$r get x1] [$r get y2]
+ } {1 xxx yyy}
+
foreach fuzztype {binary alpha compr} {
test "FUZZ stresser with data model $fuzztype" {
set err 0
- for {set i 0} {$i < 1000} {incr i} {
+ for {set i 0} {$i < 10000} {incr i} {
set fuzz [randstring 0 512 $fuzztype]
$r set foo $fuzz
set got [$r get foo]
if {$got ne $fuzz} {
- incr err
+ set err [list $fuzz $got]
break
}
}
- format $err
+ set _ $err
} {0}
}