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
92696e49
Commit
92696e49
authored
Feb 27, 2018
by
antirez
Browse files
expireIfNeeded() needed a top comment documenting the behavior.
parent
b00c4ffa
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
92696e49
...
...
@@ -1095,6 +1095,25 @@ void propagateExpire(redisDb *db, robj *key, int lazy) {
decrRefCount
(
argv
[
1
]);
}
/* This function is called when we are going to perform some operation
* in a given key, but such key may be already logically expired even if
* it still exists in the database. The main way this function is called
* is via lookupKey*() family of functions.
*
* The behavior of the function depends on the replication role of the
* instance, because slave instances do not expire keys, they wait
* for DELs from the master for consistency matters. However even
* slaves will try to have a coherent return value for the function,
* so that read commands executed in the slave side will be able to
* behave like if the key is expired even if still present (because the
* master has yet to propagate the DEL).
*
* In masters as a side effect of finding a key which is expired, such
* key will be evicted from the database. Also this may trigger the
* propagation of a DEL/UNLINK command in AOF / replication stream.
*
* The return value of the function is 0 if the key is still valid,
* otherwise the function returns 1 if the key is expired. */
int
expireIfNeeded
(
redisDb
*
db
,
robj
*
key
)
{
mstime_t
when
=
getExpire
(
db
,
key
);
mstime_t
now
;
...
...
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