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
6476f1a9
Commit
6476f1a9
authored
Jun 22, 2017
by
Salvatore Sanfilippo
Committed by
GitHub
Jun 22, 2017
Browse files
Merge pull request #4068 from FreedomU007/unstable
Fix set with ex/px option when propagated to aof
parents
ef446bf1
86e9f48a
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/aof.c
View file @
6476f1a9
...
...
@@ -536,6 +536,23 @@ void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int a
buf
=
catAppendOnlyGenericCommand
(
buf
,
3
,
tmpargv
);
decrRefCount
(
tmpargv
[
0
]);
buf
=
catAppendOnlyExpireAtCommand
(
buf
,
cmd
,
argv
[
1
],
argv
[
2
]);
}
else
if
(
cmd
->
proc
==
setCommand
&&
argc
>
3
)
{
int
i
;
robj
*
exarg
=
NULL
,
*
pxarg
=
NULL
;
/* Translate SET [EX seconds][PX milliseconds] to SET and PEXPIREAT */
buf
=
catAppendOnlyGenericCommand
(
buf
,
3
,
argv
);
for
(
i
=
3
;
i
<
argc
;
i
++
)
{
if
(
!
strcasecmp
(
argv
[
i
]
->
ptr
,
"ex"
))
exarg
=
argv
[
i
+
1
];
if
(
!
strcasecmp
(
argv
[
i
]
->
ptr
,
"px"
))
pxarg
=
argv
[
i
+
1
];
}
serverAssert
(
!
(
exarg
&&
pxarg
));
if
(
exarg
)
buf
=
catAppendOnlyExpireAtCommand
(
buf
,
server
.
expireCommand
,
argv
[
1
],
exarg
);
if
(
pxarg
)
buf
=
catAppendOnlyExpireAtCommand
(
buf
,
server
.
pexpireCommand
,
argv
[
1
],
pxarg
);
}
else
{
/* All the other commands don't need translation or need the
* same translation already operated in the command vector
...
...
src/server.c
View file @
6476f1a9
...
...
@@ -1500,6 +1500,8 @@ void initServerConfig(void) {
server.rpopCommand = lookupCommandByCString("rpop");
server.sremCommand = lookupCommandByCString("srem");
server.execCommand = lookupCommandByCString("exec");
server.expireCommand = lookupCommandByCString("expire");
server.pexpireCommand = lookupCommandByCString("pexpire");
/* Slow log */
server.slowlog_log_slower_than = CONFIG_DEFAULT_SLOWLOG_LOG_SLOWER_THAN;
...
...
src/server.h
View file @
6476f1a9
...
...
@@ -909,7 +909,8 @@ struct redisServer {
off_t
loading_process_events_interval_bytes
;
/* Fast pointers to often looked up command */
struct
redisCommand
*
delCommand
,
*
multiCommand
,
*
lpushCommand
,
*
lpopCommand
,
*
rpopCommand
,
*
sremCommand
,
*
execCommand
;
*
rpopCommand
,
*
sremCommand
,
*
execCommand
,
*
expireCommand
,
*
pexpireCommand
;
/* Fields used only for stats */
time_t
stat_starttime
;
/* Server start time */
long
long
stat_numcommands
;
/* Number of processed commands */
...
...
tests/unit/expire.tcl
View file @
6476f1a9
...
...
@@ -204,4 +204,19 @@ start_server {tags {"expire"}} {
catch
{
r expire foo
""
}
e
set e
}
{
*not an integer*
}
test
{
SET - use EX/PX option, TTL should not be reseted after loadaof
}
{
r config set appendonly yes
r set foo bar EX 100
after 2000
r debug loadaof
set ttl
[
r ttl foo
]
assert
{
$ttl
<= 98 && $ttl > 90
}
r set foo bar PX 100000
after 2000
r debug loadaof
set ttl
[
r ttl foo
]
assert
{
$ttl
<= 98 && $ttl > 90
}
}
}
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