Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
75b41de8
R
redis
项目概览
Turbo码先生
/
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,发现更多精彩内容 >>
提交
75b41de8
编写于
10月 17, 2010
作者:
P
Pieter Noordhuis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert objects in the command procs instead of the protocol code
上级
b19c33d4
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
31 addition
and
10 deletion
+31
-10
src/aof.c
src/aof.c
+0
-3
src/config.c
src/config.c
+1
-0
src/pubsub.c
src/pubsub.c
+1
-0
src/redis.c
src/redis.c
+1
-4
src/t_hash.c
src/t_hash.c
+7
-0
src/t_list.c
src/t_list.c
+7
-2
src/t_set.c
src/t_set.c
+4
-1
src/t_string.c
src/t_string.c
+5
-0
src/t_zset.c
src/t_zset.c
+5
-0
未找到文件。
src/aof.c
浏览文件 @
75b41de8
...
...
@@ -266,9 +266,6 @@ int loadAppendOnlyFile(char *filename) {
redisLog
(
REDIS_WARNING
,
"Unknown command '%s' reading the append only file"
,
argv
[
0
]
->
ptr
);
exit
(
1
);
}
/* Try object encoding */
if
(
cmd
->
flags
&
REDIS_CMD_BULK
)
argv
[
argc
-
1
]
=
tryObjectEncoding
(
argv
[
argc
-
1
]);
/* Run the command in the context of a fake client */
fakeClient
->
argc
=
argc
;
fakeClient
->
argv
=
argv
;
...
...
src/config.c
浏览文件 @
75b41de8
...
...
@@ -410,6 +410,7 @@ void configGetCommand(redisClient *c) {
}
void
configCommand
(
redisClient
*
c
)
{
c
->
argv
[
c
->
argc
-
1
]
=
tryObjectEncoding
(
c
->
argv
[
c
->
argc
-
1
]);
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"set"
))
{
if
(
c
->
argc
!=
4
)
goto
badarity
;
configSetCommand
(
c
);
...
...
src/pubsub.c
浏览文件 @
75b41de8
...
...
@@ -262,6 +262,7 @@ void punsubscribeCommand(redisClient *c) {
}
void
publishCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
int
receivers
=
pubsubPublishMessage
(
c
->
argv
[
1
],
c
->
argv
[
2
]);
addReplyLongLong
(
c
,
receivers
);
}
src/redis.c
浏览文件 @
75b41de8
...
...
@@ -914,10 +914,6 @@ int processCommand(redisClient *c) {
return
REDIS_OK
;
}
/* Let's try to encode the bulk object to save space. */
if
(
cmd
->
flags
&
REDIS_CMD_BULK
)
c
->
argv
[
c
->
argc
-
1
]
=
tryObjectEncoding
(
c
->
argv
[
c
->
argc
-
1
]);
/* Check if the user is authenticated */
if
(
server
.
requirepass
&&
!
c
->
authenticated
&&
cmd
->
proc
!=
authCommand
)
{
addReplyError
(
c
,
"operation not permitted"
);
...
...
@@ -1011,6 +1007,7 @@ void pingCommand(redisClient *c) {
}
void
echoCommand
(
redisClient
*
c
)
{
c
->
argv
[
1
]
=
tryObjectEncoding
(
c
->
argv
[
1
]);
addReplyBulk
(
c
,
c
->
argv
[
1
]);
}
...
...
src/t_hash.c
浏览文件 @
75b41de8
...
...
@@ -220,6 +220,7 @@ void hsetCommand(redisClient *c) {
robj
*
o
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
3
);
hashTypeTryObjectEncoding
(
o
,
&
c
->
argv
[
2
],
&
c
->
argv
[
3
]);
update
=
hashTypeSet
(
o
,
c
->
argv
[
2
],
c
->
argv
[
3
]);
...
...
@@ -231,6 +232,7 @@ void hsetCommand(redisClient *c) {
void
hsetnxCommand
(
redisClient
*
c
)
{
robj
*
o
;
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
3
);
if
(
hashTypeExists
(
o
,
c
->
argv
[
2
]))
{
...
...
@@ -254,6 +256,7 @@ void hmsetCommand(redisClient *c) {
}
if
((
o
=
hashTypeLookupWriteOrCreate
(
c
,
c
->
argv
[
1
]))
==
NULL
)
return
;
c
->
argv
[
c
->
argc
-
1
]
=
tryObjectEncoding
(
c
->
argv
[
c
->
argc
-
1
]);
hashTypeTryConversion
(
o
,
c
->
argv
,
2
,
c
->
argc
-
1
);
for
(
i
=
2
;
i
<
c
->
argc
;
i
+=
2
)
{
hashTypeTryObjectEncoding
(
o
,
&
c
->
argv
[
i
],
&
c
->
argv
[
i
+
1
]);
...
...
@@ -296,6 +299,7 @@ void hgetCommand(redisClient *c) {
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nullbulk
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
((
value
=
hashTypeGet
(
o
,
c
->
argv
[
2
]))
!=
NULL
)
{
addReplyBulk
(
c
,
value
);
decrRefCount
(
value
);
...
...
@@ -316,6 +320,7 @@ void hmgetCommand(redisClient *c) {
* done because objects that cannot be found are considered to be
* an empty hash. The reply should then be a series of NULLs. */
addReplyMultiBulkLen
(
c
,
c
->
argc
-
2
);
c
->
argv
[
c
->
argc
-
1
]
=
tryObjectEncoding
(
c
->
argv
[
c
->
argc
-
1
]);
for
(
i
=
2
;
i
<
c
->
argc
;
i
++
)
{
if
(
o
!=
NULL
&&
(
value
=
hashTypeGet
(
o
,
c
->
argv
[
i
]))
!=
NULL
)
{
addReplyBulk
(
c
,
value
);
...
...
@@ -331,6 +336,7 @@ void hdelCommand(redisClient *c) {
if
((
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
hashTypeDelete
(
o
,
c
->
argv
[
2
]))
{
if
(
hashTypeLength
(
o
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
addReply
(
c
,
shared
.
cone
);
...
...
@@ -395,5 +401,6 @@ void hexistsCommand(redisClient *c) {
if
((
o
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
o
,
REDIS_HASH
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
addReply
(
c
,
hashTypeExists
(
o
,
c
->
argv
[
2
])
?
shared
.
cone
:
shared
.
czero
);
}
src/t_list.c
浏览文件 @
75b41de8
...
...
@@ -260,6 +260,7 @@ void listTypeConvert(robj *subject, int enc) {
void
pushGenericCommand
(
redisClient
*
c
,
int
where
)
{
robj
*
lobj
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
lobj
==
NULL
)
{
if
(
handleClientsWaitingListPush
(
c
,
c
->
argv
[
1
],
c
->
argv
[
2
]))
{
addReply
(
c
,
shared
.
cone
);
...
...
@@ -346,14 +347,17 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
}
void
lpushxCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_HEAD
);
}
void
rpushxCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
pushxGenericCommand
(
c
,
NULL
,
c
->
argv
[
2
],
REDIS_TAIL
);
}
void
linsertCommand
(
redisClient
*
c
)
{
c
->
argv
[
4
]
=
tryObjectEncoding
(
c
->
argv
[
4
]);
if
(
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"after"
)
==
0
)
{
pushxGenericCommand
(
c
,
c
->
argv
[
3
],
c
->
argv
[
4
],
REDIS_TAIL
);
}
else
if
(
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"before"
)
==
0
)
{
...
...
@@ -409,7 +413,7 @@ void lsetCommand(redisClient *c) {
robj
*
o
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
nokeyerr
);
if
(
o
==
NULL
||
checkType
(
c
,
o
,
REDIS_LIST
))
return
;
int
index
=
atoi
(
c
->
argv
[
2
]
->
ptr
);
robj
*
value
=
c
->
argv
[
3
]
;
robj
*
value
=
(
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]))
;
listTypeTryConversion
(
o
,
value
);
if
(
o
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
...
...
@@ -559,7 +563,8 @@ void ltrimCommand(redisClient *c) {
}
void
lremCommand
(
redisClient
*
c
)
{
robj
*
subject
,
*
obj
=
c
->
argv
[
3
];
robj
*
subject
,
*
obj
;
obj
=
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
int
toremove
=
atoi
(
c
->
argv
[
2
]
->
ptr
);
int
removed
=
0
;
listTypeEntry
entry
;
...
...
src/t_set.c
浏览文件 @
75b41de8
...
...
@@ -178,6 +178,7 @@ void saddCommand(redisClient *c) {
robj
*
set
;
set
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
set
==
NULL
)
{
set
=
setTypeCreate
(
c
->
argv
[
2
]);
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
set
);
...
...
@@ -202,6 +203,7 @@ void sremCommand(redisClient *c) {
if
((
set
=
lookupKeyWriteOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
set
,
REDIS_SET
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
setTypeRemove
(
set
,
c
->
argv
[
2
]))
{
if
(
setTypeSize
(
set
)
==
0
)
dbDelete
(
c
->
db
,
c
->
argv
[
1
]);
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
...
...
@@ -216,7 +218,7 @@ void smoveCommand(redisClient *c) {
robj
*
srcset
,
*
dstset
,
*
ele
;
srcset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
dstset
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
2
]);
ele
=
c
->
argv
[
3
];
ele
=
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
])
;
/* If the source key does not exist return 0 */
if
(
srcset
==
NULL
)
{
...
...
@@ -264,6 +266,7 @@ void sismemberCommand(redisClient *c) {
if
((
set
=
lookupKeyReadOrReply
(
c
,
c
->
argv
[
1
],
shared
.
czero
))
==
NULL
||
checkType
(
c
,
set
,
REDIS_SET
))
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
setTypeIsMember
(
set
,
c
->
argv
[
2
]))
addReply
(
c
,
shared
.
cone
);
else
...
...
src/t_string.c
浏览文件 @
75b41de8
...
...
@@ -37,14 +37,17 @@ void setGenericCommand(redisClient *c, int nx, robj *key, robj *val, robj *expir
}
void
setCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
setGenericCommand
(
c
,
0
,
c
->
argv
[
1
],
c
->
argv
[
2
],
NULL
);
}
void
setnxCommand
(
redisClient
*
c
)
{
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
setGenericCommand
(
c
,
1
,
c
->
argv
[
1
],
c
->
argv
[
2
],
NULL
);
}
void
setexCommand
(
redisClient
*
c
)
{
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
setGenericCommand
(
c
,
0
,
c
->
argv
[
1
],
c
->
argv
[
3
],
c
->
argv
[
2
]);
}
...
...
@@ -69,6 +72,7 @@ void getCommand(redisClient *c) {
void
getsetCommand
(
redisClient
*
c
)
{
if
(
getGenericCommand
(
c
)
==
REDIS_ERR
)
return
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
dbReplace
(
c
->
db
,
c
->
argv
[
1
],
c
->
argv
[
2
]);
incrRefCount
(
c
->
argv
[
2
]);
touchWatchedKey
(
c
->
db
,
c
->
argv
[
1
]);
...
...
@@ -180,6 +184,7 @@ void appendCommand(redisClient *c) {
robj
*
o
;
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
if
(
o
==
NULL
)
{
/* Create the key */
retval
=
dbAdd
(
c
->
db
,
c
->
argv
[
1
],
c
->
argv
[
2
]);
...
...
src/t_zset.c
浏览文件 @
75b41de8
...
...
@@ -392,12 +392,14 @@ void zaddGenericCommand(redisClient *c, robj *key, robj *ele, double score, int
void
zaddCommand
(
redisClient
*
c
)
{
double
scoreval
;
if
(
getDoubleFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
scoreval
,
NULL
)
!=
REDIS_OK
)
return
;
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
zaddGenericCommand
(
c
,
c
->
argv
[
1
],
c
->
argv
[
3
],
scoreval
,
0
);
}
void
zincrbyCommand
(
redisClient
*
c
)
{
double
scoreval
;
if
(
getDoubleFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
scoreval
,
NULL
)
!=
REDIS_OK
)
return
;
c
->
argv
[
3
]
=
tryObjectEncoding
(
c
->
argv
[
3
]);
zaddGenericCommand
(
c
,
c
->
argv
[
1
],
c
->
argv
[
3
],
scoreval
,
1
);
}
...
...
@@ -412,6 +414,7 @@ void zremCommand(redisClient *c) {
checkType
(
c
,
zsetobj
,
REDIS_ZSET
))
return
;
zs
=
zsetobj
->
ptr
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
if
(
de
==
NULL
)
{
addReply
(
c
,
shared
.
czero
);
...
...
@@ -921,6 +924,7 @@ void zscoreCommand(redisClient *c) {
checkType
(
c
,
o
,
REDIS_ZSET
))
return
;
zs
=
o
->
ptr
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
if
(
!
de
)
{
addReply
(
c
,
shared
.
nullbulk
);
...
...
@@ -944,6 +948,7 @@ void zrankGenericCommand(redisClient *c, int reverse) {
zs
=
o
->
ptr
;
zsl
=
zs
->
zsl
;
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
2
]);
if
(
!
de
)
{
addReply
(
c
,
shared
.
nullbulk
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录