Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
64a13a36
Commit
64a13a36
authored
Apr 19, 2011
by
antirez
Browse files
variadic HDEL with tests
parent
271f0878
Changes
3
Show whitespace changes
Inline
Side-by-side
src/redis.c
View file @
64a13a36
...
@@ -138,7 +138,7 @@ struct redisCommand redisCommandTable[] = {
...
@@ -138,7 +138,7 @@ struct redisCommand redisCommandTable[] = {
{
"hmset"
,
hmsetCommand
,
-
4
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hmset"
,
hmsetCommand
,
-
4
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hmget"
,
hmgetCommand
,
-
3
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hmget"
,
hmgetCommand
,
-
3
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hincrby"
,
hincrbyCommand
,
4
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hincrby"
,
hincrbyCommand
,
4
,
REDIS_CMD_DENYOOM
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hdel"
,
hdelCommand
,
3
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hdel"
,
hdelCommand
,
-
3
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hlen"
,
hlenCommand
,
2
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hlen"
,
hlenCommand
,
2
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hkeys"
,
hkeysCommand
,
2
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hkeys"
,
hkeysCommand
,
2
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hvals"
,
hvalsCommand
,
2
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"hvals"
,
hvalsCommand
,
2
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
...
...
src/t_hash.c
View file @
64a13a36
...
@@ -396,17 +396,22 @@ void hmgetCommand(redisClient *c) {
...
@@ -396,17 +396,22 @@ void hmgetCommand(redisClient *c) {
void
hdelCommand
(
redisClient
*
c
)
{
void
hdelCommand
(
redisClient
*
c
)
{
robj
*
o
;
robj
*
o
;
int
j
,
deleted
=
0
;
if
((
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
if
((
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
if
(
hashTypeDelete
(
o
,
c
->
argv
[
2
]))
{
for
(
j
=
2
;
j
<
c
->
argc
;
j
++
)
{
if
(
hashTypeDelete
(
o
,
c
->
argv
[
j
]))
{
if
(
hashTypeLength
(
o
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
if
(
hashTypeLength
(
o
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
addReply
(
c
,
shared
.
cone
);
deleted
++
;
}
}
if
(
deleted
)
{
signalModifiedKey
(
c
->
db
,
c
->
argv
[
1
]);
signalModifiedKey
(
c
->
db
,
c
->
argv
[
1
]);
server
.
dirty
++
;
server
.
dirty
+=
deleted
;
}
else
{
addReply
(
c
,
shared
.
czero
);
}
}
addReplyLongLong
(
c
,
deleted
);
}
}
void
hlenCommand
(
redisClient
*
c
)
{
void
hlenCommand
(
redisClient
*
c
)
{
...
...
tests/unit/type/hash.tcl
View file @
64a13a36
...
@@ -226,6 +226,15 @@ start_server {tags {"hash"}} {
...
@@ -226,6 +226,15 @@ start_server {tags {"hash"}} {
set _ $rv
set _ $rv
}
{
0 0 1 0
{}
1 0
{}}
}
{
0 0 1 0
{}
1 0
{}}
test
{
HDEL - more than a single value
}
{
set rv
{}
r del myhash
r hmset myhash a 1 b 2 c 3
assert_equal 0
[
r hdel myhash x y
]
assert_equal 2
[
r hdel myhash a c f
]
r hgetall myhash
}
{
b 2
}
test
{
HEXISTS
}
{
test
{
HEXISTS
}
{
set rv
{}
set rv
{}
set k
[
lindex
[
array names smallhash *
]
0
]
set k
[
lindex
[
array names smallhash *
]
0
]
...
...
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