Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d4a3cfed
Commit
d4a3cfed
authored
Nov 14, 2011
by
antirez
Browse files
Merge branch 'unstable' into incrbyfloat
parents
70023978
762eea07
Changes
6
Show whitespace changes
Inline
Side-by-side
src/aof.c
View file @
d4a3cfed
...
@@ -431,7 +431,7 @@ int rewriteAppendOnlyFile(char *filename) {
...
@@ -431,7 +431,7 @@ int rewriteAppendOnlyFile(char *filename) {
FILE
*
fp
;
FILE
*
fp
;
char
tmpfile
[
256
];
char
tmpfile
[
256
];
int
j
;
int
j
;
time_t
now
=
time
(
NULL
);
long
long
now
=
ms
time
();
/* Note that we have to use a different temp name here compared to the
/* Note that we have to use a different temp name here compared to the
* one used by rewriteAppendOnlyFileBackground() function. */
* one used by rewriteAppendOnlyFileBackground() function. */
...
@@ -462,7 +462,7 @@ int rewriteAppendOnlyFile(char *filename) {
...
@@ -462,7 +462,7 @@ int rewriteAppendOnlyFile(char *filename) {
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
sds
keystr
;
sds
keystr
;
robj
key
,
*
o
;
robj
key
,
*
o
;
time_t
expiretime
;
long
long
expiretime
;
keystr
=
dictGetKey
(
de
);
keystr
=
dictGetKey
(
de
);
o
=
dictGetVal
(
de
);
o
=
dictGetVal
(
de
);
...
...
src/debug.c
View file @
d4a3cfed
...
@@ -91,7 +91,7 @@ void computeDatasetDigest(unsigned char *final) {
...
@@ -91,7 +91,7 @@ void computeDatasetDigest(unsigned char *final) {
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
sds
key
;
sds
key
;
robj
*
keyobj
,
*
o
;
robj
*
keyobj
,
*
o
;
time_t
expiretime
;
long
long
expiretime
;
memset
(
digest
,
0
,
20
);
/* This key-val digest */
memset
(
digest
,
0
,
20
);
/* This key-val digest */
key
=
dictGetKey
(
de
);
key
=
dictGetKey
(
de
);
...
...
src/rdb.c
View file @
d4a3cfed
...
@@ -597,7 +597,7 @@ int rdbSave(char *filename) {
...
@@ -597,7 +597,7 @@ int rdbSave(char *filename) {
dictEntry
*
de
;
dictEntry
*
de
;
char
tmpfile
[
256
];
char
tmpfile
[
256
];
int
j
;
int
j
;
time_t
now
=
mstime
();
long
long
now
=
mstime
();
FILE
*
fp
;
FILE
*
fp
;
rio
rdb
;
rio
rdb
;
...
...
src/redis.c
View file @
d4a3cfed
...
@@ -563,17 +563,17 @@ void activeExpireCycle(void) {
...
@@ -563,17 +563,17 @@ void activeExpireCycle(void) {
* of the keys were expired. */
* of the keys were expired. */
do
{
do
{
long
num
=
dictSize
(
db
->
expires
);
long
num
=
dictSize
(
db
->
expires
);
time_t
now
=
time
(
NULL
);
long
long
now
=
ms
time
();
expired
=
0
;
expired
=
0
;
if
(
num
>
REDIS_EXPIRELOOKUPS_PER_CRON
)
if
(
num
>
REDIS_EXPIRELOOKUPS_PER_CRON
)
num
=
REDIS_EXPIRELOOKUPS_PER_CRON
;
num
=
REDIS_EXPIRELOOKUPS_PER_CRON
;
while
(
num
--
)
{
while
(
num
--
)
{
dictEntry
*
de
;
dictEntry
*
de
;
time_t
t
;
long
long
t
;
if
((
de
=
dictGetRandomKey
(
db
->
expires
))
==
NULL
)
break
;
if
((
de
=
dictGetRandomKey
(
db
->
expires
))
==
NULL
)
break
;
t
=
(
time_t
)
dictGet
Val
(
de
);
t
=
dictGetSignedInteger
Val
(
de
);
if
(
now
>
t
)
{
if
(
now
>
t
)
{
sds
key
=
dictGetKey
(
de
);
sds
key
=
dictGetKey
(
de
);
robj
*
keyobj
=
createStringObject
(
key
,
sdslen
(
key
));
robj
*
keyobj
=
createStringObject
(
key
,
sdslen
(
key
));
...
...
src/redis.h
View file @
d4a3cfed
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
/* Static server configuration */
/* Static server configuration */
#define REDIS_SERVERPORT 6379
/* TCP port */
#define REDIS_SERVERPORT 6379
/* TCP port */
#define REDIS_MAXIDLETIME
(60*5)
/* default client timeout */
#define REDIS_MAXIDLETIME
0
/* default client timeout
: infinite
*/
#define REDIS_IOBUF_LEN (1024*16)
#define REDIS_IOBUF_LEN (1024*16)
#define REDIS_LOADBUF_LEN 1024
#define REDIS_LOADBUF_LEN 1024
#define REDIS_DEFAULT_DBNUM 16
#define REDIS_DEFAULT_DBNUM 16
...
...
tests/unit/expire.tcl
View file @
d4a3cfed
...
@@ -127,4 +127,18 @@ start_server {tags {"expire"}} {
...
@@ -127,4 +127,18 @@ start_server {tags {"expire"}} {
set ttl
[
r pttl x
]
set ttl
[
r pttl x
]
assert
{
$ttl
> 900 && $ttl <= 1000
}
assert
{
$ttl
> 900 && $ttl <= 1000
}
}
}
test
{
Redis should actively expire keys incrementally
}
{
r flushdb
r psetex key1 500 a
r psetex key2 500 a
r psetex key3 500 a
set size1
[
r dbsize
]
# Redis expires random keys ten times every second so we are
# fairly sure that all the three keys should be evicted after
# one second.
after 1000
set size2
[
r dbsize
]
list $size1 $size2
}
{
3 0
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment