Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hanoi2005
redis
提交
8686a703
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,发现更多精彩内容 >>
提交
8686a703
编写于
8月 06, 2013
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove dead code and fix comments for new expire code.
上级
d54e373b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
56 deletion
+10
-56
src/redis.c
src/redis.c
+10
-56
未找到文件。
src/redis.c
浏览文件 @
8686a703
...
...
@@ -665,12 +665,14 @@ int activeExpireCycleTryExpire(redisDb *db, struct dictEntry *de, long long now)
* No more than REDIS_DBCRON_DBS_PER_CALL databases are tested at every
* iteration.
*
* If fast is non-zero the function will try to expire just one key ASAP
* from the current DB and return. This kind of call is used when Redis detects
* that timelimit_exit is true, so there is more work to do, and we do it
* more incrementally from the beforeSleep() function of the event loop. */
* If fast is non-zero the function will try to run a "fast" expire cycle that
* takes no longer than EXPIRE_FAST_CYCLE_DURATION microseconds, and is not
* repeated again before the same amount of time.
*
* This kind of call is used when Redis detects that timelimit_exit is
* true, so there is more work to do, and we do it more incrementally from
* the beforeSleep() function of the event loop. */
#define EXPIRED_HISTORY_LEN 10
#define EXPIRE_FAST_CYCLE_DURATION 1000
void
activeExpireCycle
(
int
fast
)
{
...
...
@@ -684,41 +686,15 @@ void activeExpireCycle(int fast) {
long
long
start
=
ustime
(),
timelimit
;
static
long
long
last_fast_cycle
=
0
;
#if 0
static int expired_history[EXPIRED_HISTORY_LEN];
static int expired_history_id = 0;
static int expired_perc_avg = 0;
#endif
if
(
fast
)
{
/* Don't start a fast cycle if the previous cycle did not exited
* for time limt. Also don't repeat a fast cycle for the same period
* as the fast cycle total duration itself. */
if
(
!
timelimit_exit
)
return
;
if
(
start
<
last_fast_cycle
+
EXPIRE_FAST_CYCLE_DURATION
)
{
printf
(
"CANT START A FAST CYCLE
\n
"
);
return
;
}
if
(
start
<
last_fast_cycle
+
EXPIRE_FAST_CYCLE_DURATION
)
return
;
last_fast_cycle
=
start
;
}
#if 0
if (fast) {
if (!timelimit_exit) return;
/* Let's try to expire a single key from the previous DB, the one that
* had enough keys expiring to reach the time limit. */
redisDb *db = server.db+((current_db+server.dbnum-1) % server.dbnum);
dictEntry *de;
for (j = 0; j < 100; j++) {
if ((de = dictGetRandomKey(db->expires)) == NULL) break;
activeExpireCycleTryExpire(db,de,server.mstime);
}
return;
}
#endif
/* We usually should test REDIS_DBCRON_DBS_PER_CALL per iteration, with
* two exceptions:
*
...
...
@@ -785,19 +761,6 @@ void activeExpireCycle(int fast) {
{
timelimit_exit
=
1
;
}
#if 0
expired_history_id = (expired_history_id+1) % EXPIRED_HISTORY_LEN;
expired_history[expired_history_id] = expired;
{
int i;
expired_perc_avg = 0;
for (i = 0; i < EXPIRED_HISTORY_LEN; i++) {
expired_perc_avg += expired_history[i];
}
expired_perc_avg = (expired_perc_avg * 100) / (REDIS_EXPIRELOOKUPS_PER_CRON*EXPIRED_HISTORY_LEN);
// printf("Expired AVG: %d\n", expired_perc_avg);
}
#endif
if
(
timelimit_exit
)
return
;
}
while
(
expired
>
REDIS_EXPIRELOOKUPS_PER_CRON
/
4
);
}
...
...
@@ -918,12 +881,8 @@ void clientsCron(void) {
void
databasesCron
(
void
)
{
/* Expire keys by random sampling. Not required for slaves
* as master will synthesize DELs for us. */
if
(
server
.
active_expire_enabled
&&
server
.
masterhost
==
NULL
)
{
long
long
totalex
=
server
.
stat_expiredkeys
;
if
(
server
.
active_expire_enabled
&&
server
.
masterhost
==
NULL
)
activeExpireCycle
(
0
);
if
(
server
.
stat_expiredkeys
-
totalex
)
printf
(
"EXPIRED SLOW: %lld
\n
"
,
server
.
stat_expiredkeys
-
totalex
);
}
/* Perform hash tables rehashing if needed, but only if there are no
* other processes saving the DB on disk. Otherwise rehashing is bad
...
...
@@ -1156,12 +1115,7 @@ void beforeSleep(struct aeEventLoop *eventLoop) {
redisClient
*
c
;
/* Run a fast expire cycle. */
{
long
long
totalex
=
server
.
stat_expiredkeys
;
activeExpireCycle
(
1
);
if
(
server
.
stat_expiredkeys
-
totalex
)
printf
(
"EXPIRED FAST: %lld
\n
"
,
server
.
stat_expiredkeys
-
totalex
);
}
activeExpireCycle
(
1
);
/* Try to process pending commands for clients that were just unblocked. */
while
(
listLength
(
server
.
unblocked_clients
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录