Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
fd8ccf44
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
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,发现更多精彩内容 >>
提交
fd8ccf44
编写于
10月 23, 2009
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work on ZSETs and a new make target called 32bit to build i386 binaries on mac os x leopard
上级
6b47e12e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
1 deletion
+85
-1
Makefile
Makefile
+4
-1
redis-cli.c
redis-cli.c
+1
-0
redis.c
redis.c
+80
-0
未找到文件。
Makefile
浏览文件 @
fd8ccf44
...
...
@@ -4,7 +4,7 @@
DEBUG
?=
-g
-rdynamic
-ggdb
CFLAGS
?=
-std
=
c99
-O2
-pedantic
-Wall
-W
CCOPT
=
$(CFLAGS)
CCOPT
=
$(CFLAGS)
$(ARCH)
OBJ
=
adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o
BENCHOBJ
=
ae.o anet.o benchmark.o sds.o adlist.o zmalloc.o
...
...
@@ -61,3 +61,6 @@ bench:
log
:
git log
'--pretty=format:%ad %s'
--date
=
short
>
Changelog
32bit
:
make
ARCH
=
"-arch i386"
redis-cli.c
浏览文件 @
fd8ccf44
...
...
@@ -89,6 +89,7 @@ static struct redisCommand cmdTable[] = {
{
"sdiff"
,
-
2
,
REDIS_CMD_INLINE
},
{
"sdiffstore"
,
-
3
,
REDIS_CMD_INLINE
},
{
"smembers"
,
2
,
REDIS_CMD_INLINE
},
{
"zadd"
,
4
,
REDIS_CMD_BULK
},
{
"incrby"
,
3
,
REDIS_CMD_INLINE
},
{
"decrby"
,
3
,
REDIS_CMD_INLINE
},
{
"getset"
,
3
,
REDIS_CMD_BULK
},
...
...
redis.c
浏览文件 @
fd8ccf44
...
...
@@ -370,6 +370,7 @@ static void rdbRemoveTempFile(pid_t childpid);
static
size_t
stringObjectLen
(
robj
*
o
);
static
void
processInputBuffer
(
redisClient
*
c
);
static
zskiplist
*
zslCreate
(
void
);
static
void
zslFree
(
zskiplist
*
zsl
);
static
void
authCommand
(
redisClient
*
c
);
static
void
pingCommand
(
redisClient
*
c
);
...
...
@@ -432,6 +433,7 @@ static void slaveofCommand(redisClient *c);
static
void
debugCommand
(
redisClient
*
c
);
static
void
msetCommand
(
redisClient
*
c
);
static
void
msetnxCommand
(
redisClient
*
c
);
static
void
zaddCommand
(
redisClient
*
c
);
/*================================= Globals ================================= */
...
...
@@ -470,6 +472,7 @@ static struct redisCommand cmdTable[] = {
{
"sdiff"
,
sdiffCommand
,
-
2
,
REDIS_CMD_INLINE
|
REDIS_CMD_DENYOOM
},
{
"sdiffstore"
,
sdiffstoreCommand
,
-
3
,
REDIS_CMD_INLINE
|
REDIS_CMD_DENYOOM
},
{
"smembers"
,
sinterCommand
,
2
,
REDIS_CMD_INLINE
},
{
"zadd"
,
zaddCommand
,
4
,
REDIS_CMD_BULK
|
REDIS_CMD_DENYOOM
},
{
"incrby"
,
incrbyCommand
,
3
,
REDIS_CMD_INLINE
|
REDIS_CMD_DENYOOM
},
{
"decrby"
,
decrbyCommand
,
3
,
REDIS_CMD_INLINE
|
REDIS_CMD_DENYOOM
},
{
"getset"
,
getsetCommand
,
3
,
REDIS_CMD_BULK
|
REDIS_CMD_DENYOOM
},
...
...
@@ -1863,6 +1866,14 @@ static void freeSetObject(robj *o) {
dictRelease
((
dict
*
)
o
->
ptr
);
}
static
void
freeZsetObject
(
robj
*
o
)
{
zset
*
zs
=
o
->
ptr
;
dictRelease
(
zs
->
dict
);
zslFree
(
zs
->
zsl
);
zfree
(
zs
);
}
static
void
freeHashObject
(
robj
*
o
)
{
dictRelease
((
dict
*
)
o
->
ptr
);
}
...
...
@@ -1887,6 +1898,7 @@ static void decrRefCount(void *obj) {
case
REDIS_STRING
:
freeStringObject
(
o
);
break
;
case
REDIS_LIST
:
freeListObject
(
o
);
break
;
case
REDIS_SET
:
freeSetObject
(
o
);
break
;
case
REDIS_ZSET
:
freeZsetObject
(
o
);
break
;
case
REDIS_HASH
:
freeHashObject
(
o
);
break
;
default:
assert
(
0
!=
0
);
break
;
}
...
...
@@ -3704,6 +3716,21 @@ static zskiplist *zslCreate(void) {
return
zsl
;
}
static
void
zslFreeNode
(
zskiplistNode
*
node
)
{
decrRefCount
(
node
->
obj
);
zfree
(
node
);
}
static
void
zslFree
(
zskiplist
*
zsl
)
{
zskiplistNode
*
node
=
zsl
->
header
->
forward
[
1
],
*
next
;
while
(
node
)
{
next
=
node
->
forward
[
1
];
zslFreeNode
(
node
);
node
=
next
;
}
}
static
int
zslRandomLevel
(
void
)
{
int
level
=
1
;
while
((
random
()
&
0xFFFF
)
<
(
ZSKIPLIST_P
*
0xFFFF
))
...
...
@@ -3739,6 +3766,59 @@ static void zslInsert(zskiplist *zsl, double score, robj *obj) {
}
}
static
int
zslDelete
(
zskiplist
*
zsl
,
double
score
,
robj
*
obj
)
{
return
1
;
}
/* The actual Z-commands implementations */
static
void
zaddCommand
(
redisClient
*
c
)
{
robj
*
zsetobj
;
zset
*
zs
;
double
*
score
;
zsetobj
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
if
(
zsetobj
==
NULL
)
{
zsetobj
=
createZsetObject
();
dictAdd
(
c
->
db
->
dict
,
c
->
argv
[
1
],
zsetobj
);
incrRefCount
(
c
->
argv
[
1
]);
}
else
{
if
(
zsetobj
->
type
!=
REDIS_ZSET
)
{
addReply
(
c
,
shared
.
wrongtypeerr
);
return
;
}
}
score
=
zmalloc
(
sizeof
(
double
));
*
score
=
strtod
(
c
->
argv
[
2
]
->
ptr
,
NULL
);
zs
=
zsetobj
->
ptr
;
if
(
dictAdd
(
zs
->
dict
,
c
->
argv
[
3
],
score
)
==
DICT_OK
)
{
/* case 1: New element */
incrRefCount
(
c
->
argv
[
3
]);
/* added to hash */
zslInsert
(
zs
->
zsl
,
*
score
,
c
->
argv
[
3
]);
incrRefCount
(
c
->
argv
[
3
]);
/* added to skiplist */
server
.
dirty
++
;
addReply
(
c
,
shared
.
cone
);
}
else
{
dictEntry
*
de
;
double
*
oldscore
;
/* case 2: Score update operation */
de
=
dictFind
(
zs
->
dict
,
c
->
argv
[
3
]);
assert
(
de
!=
NULL
);
oldscore
=
dictGetEntryVal
(
de
);
if
(
*
score
!=
*
oldscore
)
{
int
deleted
;
deleted
=
zslDelete
(
zs
->
zsl
,
*
score
,
c
->
argv
[
3
]);
assert
(
deleted
!=
0
);
zslInsert
(
zs
->
zsl
,
*
score
,
c
->
argv
[
3
]);
incrRefCount
(
c
->
argv
[
3
]);
server
.
dirty
++
;
}
addReply
(
c
,
shared
.
czero
);
}
}
/* ========================= Non type-specific commands ==================== */
static
void
flushdbCommand
(
redisClient
*
c
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录