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
a539d29a
Commit
a539d29a
authored
Aug 03, 2010
by
antirez
Browse files
PERSIST command implemented
parent
6146329f
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
a539d29a
...
@@ -394,11 +394,7 @@ int removeExpire(redisDb *db, robj *key) {
...
@@ -394,11 +394,7 @@ int removeExpire(redisDb *db, robj *key) {
/* An expire may only be removed if there is a corresponding entry in the
/* An expire may only be removed if there is a corresponding entry in the
* main dict. Otherwise, the key will never be freed. */
* main dict. Otherwise, the key will never be freed. */
redisAssert
(
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
redisAssert
(
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
if
(
dictDelete
(
db
->
expires
,
key
->
ptr
)
==
DICT_OK
)
{
return
dictDelete
(
db
->
expires
,
key
->
ptr
)
==
DICT_OK
;
return
1
;
}
else
{
return
0
;
}
}
}
void
setExpire
(
redisDb
*
db
,
robj
*
key
,
time_t
when
)
{
void
setExpire
(
redisDb
*
db
,
robj
*
key
,
time_t
when
)
{
...
@@ -528,3 +524,17 @@ void ttlCommand(redisClient *c) {
...
@@ -528,3 +524,17 @@ void ttlCommand(redisClient *c) {
}
}
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
":%d
\r\n
"
,
ttl
));
addReplySds
(
c
,
sdscatprintf
(
sdsempty
(),
":%d
\r\n
"
,
ttl
));
}
}
void
persistCommand
(
redisClient
*
c
)
{
dictEntry
*
de
;
de
=
dictFind
(
c
->
db
->
dict
,
c
->
argv
[
1
]
->
ptr
);
if
(
de
==
NULL
)
{
addReply
(
c
,
shared
.
czero
);
}
else
{
if
(
removeExpire
(
c
->
db
,
c
->
argv
[
1
]))
addReply
(
c
,
shared
.
cone
);
else
addReply
(
c
,
shared
.
czero
);
}
}
src/redis.c
View file @
a539d29a
...
@@ -170,6 +170,7 @@ struct redisCommand readonlyCommandTable[] = {
...
@@ -170,6 +170,7 @@ struct redisCommand readonlyCommandTable[] = {
{
"info"
,
infoCommand
,
1
,
REDIS_CMD_INLINE
,
NULL
,
0
,
0
,
0
},
{
"info"
,
infoCommand
,
1
,
REDIS_CMD_INLINE
,
NULL
,
0
,
0
,
0
},
{
"monitor"
,
monitorCommand
,
1
,
REDIS_CMD_INLINE
,
NULL
,
0
,
0
,
0
},
{
"monitor"
,
monitorCommand
,
1
,
REDIS_CMD_INLINE
,
NULL
,
0
,
0
,
0
},
{
"ttl"
,
ttlCommand
,
2
,
REDIS_CMD_INLINE
,
NULL
,
1
,
1
,
1
},
{
"ttl"
,
ttlCommand
,
2
,
REDIS_CMD_INLINE
,
NULL
,
1
,
1
,
1
},
{
"persist"
,
persistCommand
,
2
,
REDIS_CMD_INLINE
,
NULL
,
1
,
1
,
1
},
{
"slaveof"
,
slaveofCommand
,
3
,
REDIS_CMD_INLINE
,
NULL
,
0
,
0
,
0
},
{
"slaveof"
,
slaveofCommand
,
3
,
REDIS_CMD_INLINE
,
NULL
,
0
,
0
,
0
},
{
"debug"
,
debugCommand
,
-
2
,
REDIS_CMD_INLINE
,
NULL
,
0
,
0
,
0
},
{
"debug"
,
debugCommand
,
-
2
,
REDIS_CMD_INLINE
,
NULL
,
0
,
0
,
0
},
{
"config"
,
configCommand
,
-
2
,
REDIS_CMD_BULK
,
NULL
,
0
,
0
,
0
},
{
"config"
,
configCommand
,
-
2
,
REDIS_CMD_BULK
,
NULL
,
0
,
0
,
0
},
...
...
src/redis.h
View file @
a539d29a
...
@@ -838,6 +838,7 @@ void expireCommand(redisClient *c);
...
@@ -838,6 +838,7 @@ void expireCommand(redisClient *c);
void
expireatCommand
(
redisClient
*
c
);
void
expireatCommand
(
redisClient
*
c
);
void
getsetCommand
(
redisClient
*
c
);
void
getsetCommand
(
redisClient
*
c
);
void
ttlCommand
(
redisClient
*
c
);
void
ttlCommand
(
redisClient
*
c
);
void
persistCommand
(
redisClient
*
c
);
void
slaveofCommand
(
redisClient
*
c
);
void
slaveofCommand
(
redisClient
*
c
);
void
debugCommand
(
redisClient
*
c
);
void
debugCommand
(
redisClient
*
c
);
void
msetCommand
(
redisClient
*
c
);
void
msetCommand
(
redisClient
*
c
);
...
...
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