Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ad01a255
Commit
ad01a255
authored
Dec 31, 2010
by
antirez
Browse files
blocking load of keys on lookup -- nor tested, nor finished
parent
4e941eca
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
ad01a255
...
@@ -27,10 +27,26 @@ robj *lookupKey(redisDb *db, robj *key) {
...
@@ -27,10 +27,26 @@ robj *lookupKey(redisDb *db, robj *key) {
server
.
stat_keyspace_hits
++
;
server
.
stat_keyspace_hits
++
;
return
val
;
return
val
;
}
else
{
}
else
{
/* FIXME: Check if the object is on disk, if it is, load it
time_t
expire
;
* in a blocking way now. If we are sure there are no collisions
robj
*
val
;
* it would be cool to load this directly here without IO thread
* help. */
/* Key not found in the in memory hash table, but if disk store is
* enabled we may have this key on disk. If so load it in memory
* in a blocking way.
*
* FIXME: race condition here. If there was an already scheduled
* async loading of this key, what may happen is that the old
* key is loaded in memory if this gets deleted in the meantime. */
if
(
server
.
ds_enabled
&&
cacheKeyMayExist
(
db
,
key
))
{
val
=
dsGet
(
db
,
key
,
&
expire
);
if
(
val
)
{
int
retval
=
dbAdd
(
db
,
key
,
val
);
redisAssert
(
retval
==
REDIS_OK
);
if
(
expire
!=
-
1
)
setExpire
(
db
,
key
,
expire
);
server
.
stat_keyspace_hits
++
;
return
val
;
}
}
server
.
stat_keyspace_misses
++
;
server
.
stat_keyspace_misses
++
;
return
NULL
;
return
NULL
;
}
}
...
...
src/dscache.c
View file @
ad01a255
...
@@ -292,9 +292,13 @@ void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
...
@@ -292,9 +292,13 @@ void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
if
(
j
->
type
==
REDIS_IOJOB_LOAD
)
{
if
(
j
->
type
==
REDIS_IOJOB_LOAD
)
{
/* Create the key-value pair in the in-memory database */
/* Create the key-value pair in the in-memory database */
if
(
j
->
val
!=
NULL
)
{
if
(
j
->
val
!=
NULL
)
{
dbAdd
(
j
->
db
,
j
->
key
,
j
->
val
);
/* Note: the key may already be here if between the time
incrRefCount
(
j
->
val
);
* this key loading was scheduled and now there was the
if
(
j
->
expire
!=
-
1
)
setExpire
(
j
->
db
,
j
->
key
,
j
->
expire
);
* need to blocking load the key for a key lookup. */
if
(
dbAdd
(
j
->
db
,
j
->
key
,
j
->
val
)
==
REDIS_OK
)
{
incrRefCount
(
j
->
val
);
if
(
j
->
expire
!=
-
1
)
setExpire
(
j
->
db
,
j
->
key
,
j
->
expire
);
}
}
else
{
}
else
{
/* The key does not exist. Create a negative cache entry
/* The key does not exist. Create a negative cache entry
* for this key. */
* for this key. */
...
...
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