Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
31222292
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
31222292
编写于
12月 30, 2010
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handled DEL command as a special optimized case for disk store
上级
8d51fb6a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
5 deletion
+34
-5
src/db.c
src/db.c
+12
-0
src/diskstore.c
src/diskstore.c
+4
-0
src/dscache.c
src/dscache.c
+17
-5
src/redis.h
src/redis.h
+1
-0
未找到文件。
src/db.c
浏览文件 @
31222292
...
...
@@ -205,10 +205,22 @@ void delCommand(redisClient *c) {
int
deleted
=
0
,
j
;
for
(
j
=
1
;
j
<
c
->
argc
;
j
++
)
{
if
(
server
.
ds_enabled
)
{
lookupKeyRead
(
c
->
db
,
c
->
argv
[
j
]);
/* FIXME: this can be optimized a lot, no real need to load
* a possibly huge value. */
}
if
(
dbDelete
(
c
->
db
,
c
->
argv
[
j
]))
{
signalModifiedKey
(
c
->
db
,
c
->
argv
[
j
]);
server
.
dirty
++
;
deleted
++
;
}
else
if
(
server
.
ds_enabled
)
{
if
(
cacheKeyMayExist
(
c
->
db
,
c
->
argv
[
j
])
&&
dsExists
(
c
->
db
,
c
->
argv
[
j
]))
{
cacheScheduleForFlush
(
c
->
db
,
c
->
argv
[
j
]);
deleted
=
1
;
}
}
}
addReplyLongLong
(
c
,
deleted
);
...
...
src/diskstore.c
浏览文件 @
31222292
...
...
@@ -262,6 +262,10 @@ int dsDel(redisDb *db, robj *key) {
}
int
dsExists
(
redisDb
*
db
,
robj
*
key
)
{
char
buf
[
1024
];
dsKeyToPath
(
db
,
buf
,
key
);
return
access
(
buf
,
R_OK
)
==
0
;
}
int
dsFlushDb
(
int
dbid
)
{
...
...
src/dscache.c
浏览文件 @
31222292
...
...
@@ -304,8 +304,10 @@ void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
handleClientsBlockedOnSwappedKey
(
j
->
db
,
j
->
key
);
freeIOJob
(
j
);
}
else
if
(
j
->
type
==
REDIS_IOJOB_SAVE
)
{
redisAssert
(
j
->
val
->
storage
==
REDIS_DS_SAVING
);
j
->
val
->
storage
=
REDIS_DS_MEMORY
;
if
(
j
->
val
)
{
redisAssert
(
j
->
val
->
storage
==
REDIS_DS_SAVING
);
j
->
val
->
storage
=
REDIS_DS_MEMORY
;
}
freeIOJob
(
j
);
}
processed
++
;
...
...
@@ -362,11 +364,12 @@ void *IOThreadEntryPoint(void *arg) {
j
->
val
=
dsGet
(
j
->
db
,
j
->
key
,
&
expire
);
if
(
j
->
val
)
j
->
expire
=
expire
;
}
else
if
(
j
->
type
==
REDIS_IOJOB_SAVE
)
{
redisAssert
(
j
->
val
->
storage
==
REDIS_DS_SAVING
);
if
(
j
->
val
)
if
(
j
->
val
)
{
redisAssert
(
j
->
val
->
storage
==
REDIS_DS_SAVING
);
dsSet
(
j
->
db
,
j
->
key
,
j
->
val
);
else
}
else
{
dsDel
(
j
->
db
,
j
->
key
);
}
}
/* Done: insert the job into the processed queue */
...
...
@@ -540,6 +543,15 @@ void cacheCron(void) {
}
}
/* ============ Negative caching for diskstore objects ====================== */
/* Since accesses to keys that don't exist with disk store cost us a disk
* access, we need to cache names of keys that do not exist but are frequently
* accessed. */
int
cacheKeyMayExist
(
redisDb
*
db
,
robj
*
key
)
{
/* FIXME: for now we just always return true. */
return
1
;
}
/* ============ Virtual Memory - Blocking clients on missing keys =========== */
/* This function makes the clinet 'c' waiting for the key 'key' to be loaded.
...
...
src/redis.h
浏览文件 @
31222292
...
...
@@ -808,6 +808,7 @@ void handleClientsBlockedOnSwappedKey(redisDb *db, robj *key);
int
cacheFreeOneEntry
(
void
);
void
cacheScheduleForFlush
(
redisDb
*
db
,
robj
*
key
);
void
cacheCron
(
void
);
int
cacheKeyMayExist
(
redisDb
*
db
,
robj
*
key
);
/* Set data type */
robj
*
setTypeCreate
(
robj
*
value
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录