Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hanoi2005
redis
提交
a86f14b1
R
redis
项目概览
hanoi2005
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a86f14b1
编写于
3月 17, 2010
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
HEXISTS and tests implemented
上级
11d9d1e3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
1 deletion
+36
-1
redis-cli.c
redis-cli.c
+1
-0
redis.c
redis.c
+22
-0
redis.tcl
redis.tcl
+1
-1
test-redis.tcl
test-redis.tcl
+12
-0
未找到文件。
redis-cli.c
浏览文件 @
a86f14b1
...
...
@@ -153,6 +153,7 @@ static struct redisCommand cmdTable[] = {
{
"hkeys"
,
2
,
REDIS_CMD_INLINE
},
{
"hvals"
,
2
,
REDIS_CMD_INLINE
},
{
"hgetall"
,
2
,
REDIS_CMD_INLINE
},
{
"hexists"
,
3
,
REDIS_CMD_BULK
},
{
NULL
,
0
,
0
}
};
...
...
redis.c
浏览文件 @
a86f14b1
...
...
@@ -689,6 +689,7 @@ static void zinterCommand(redisClient *c);
static
void
hkeysCommand
(
redisClient
*
c
);
static
void
hvalsCommand
(
redisClient
*
c
);
static
void
hgetallCommand
(
redisClient
*
c
);
static
void
hexistsCommand
(
redisClient
*
c
);
/*================================= Globals ================================= */
...
...
@@ -754,6 +755,7 @@ static struct redisCommand cmdTable[] = {
{
"hkeys"
,
hkeysCommand
,
2
,
REDIS_CMD_INLINE
,
1
,
1
,
1
},
{
"hvals"
,
hvalsCommand
,
2
,
REDIS_CMD_INLINE
,
1
,
1
,
1
},
{
"hgetall"
,
hgetallCommand
,
2
,
REDIS_CMD_INLINE
,
1
,
1
,
1
},
{
"hexists"
,
hexistsCommand
,
3
,
REDIS_CMD_BULK
,
1
,
1
,
1
},
{
"incrby"
,
incrbyCommand
,
3
,
REDIS_CMD_INLINE
|
REDIS_CMD_DENYOOM
,
1
,
1
,
1
},
{
"decrby"
,
decrbyCommand
,
3
,
REDIS_CMD_INLINE
|
REDIS_CMD_DENYOOM
,
1
,
1
,
1
},
{
"getset"
,
getsetCommand
,
3
,
REDIS_CMD_BULK
|
REDIS_CMD_DENYOOM
,
1
,
1
,
1
},
...
...
@@ -5995,6 +5997,26 @@ static void hgetallCommand(redisClient *c) {
genericHgetallCommand
(
c
,
REDIS_GETALL_KEYS
|
REDIS_GETALL_VALS
);
}
static
void
hexistsCommand
(
redisClient
*
c
)
{
robj
*
o
;
int
exists
=
0
;
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPMAP
)
{
robj
*
field
;
unsigned
char
*
zm
=
o
->
ptr
;
field
=
getDecodedObject
(
c
->
argv
[
2
]);
exists
=
zipmapExists
(
zm
,
field
->
ptr
,
sdslen
(
field
->
ptr
));
decrRefCount
(
field
);
}
else
{
exists
=
dictFind
(
o
->
ptr
,
c
->
argv
[
2
])
!=
NULL
;
}
addReply
(
c
,
exists
?
shared
.
cone
:
shared
.
czero
);
}
static
void
convertToRealHash
(
robj
*
o
)
{
unsigned
char
*
key
,
*
val
,
*
p
,
*
zm
=
o
->
ptr
;
unsigned
int
klen
,
vlen
;
...
...
redis.tcl
浏览文件 @
a86f14b1
...
...
@@ -20,7 +20,7 @@ array set ::redis::multibulkarg {}
# Flag commands requiring last argument as a bulk write operation
foreach redis_bulk_cmd
{
set setnx rpush lpush lset lrem sadd srem sismember echo getset smove zadd zrem zscore zincrby append zrank zrevrank hget hdel
set setnx rpush lpush lset lrem sadd srem sismember echo getset smove zadd zrem zscore zincrby append zrank zrevrank hget hdel
hexists
}
{
set ::redis::bulkarg
(
$redis
_bulk_cmd
)
{}
}
...
...
test-redis.tcl
浏览文件 @
a86f14b1
...
...
@@ -1644,13 +1644,25 @@ proc main {server port} {
lappend rv
[
$r
hdel smallhash $k
]
lappend rv
[
$r
hdel smallhash $k
]
lappend rv
[
$r
hget smallhash $k
]
unset smallhash
(
$k
)
set k
[
lindex
[
array names bighash *
]
0
]
lappend rv
[
$r
hdel bighash $k
]
lappend rv
[
$r
hdel bighash $k
]
lappend rv
[
$r
hget bighash $k
]
unset bighash
(
$k
)
set _ $rv
}
{
0 0 1 0
{}
1 0
{}}
test
{
HEXISTS
}
{
set rv
{}
set k
[
lindex
[
array names smallhash *
]
0
]
lappend rv
[
$r
hexists smallhash $k
]
lappend rv
[
$r
hexists smallhash nokey
]
set k
[
lindex
[
array names bighash *
]
0
]
lappend rv
[
$r
hexists bighash $k
]
lappend rv
[
$r
hexists bighash nokey
]
}
{
1 0 1 0
}
test
{
Is a zipmap encoded Hash promoted on big payload?
}
{
$r hset smallhash foo
[
string repeat a 1024
]
$r debug object smallhash
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录