summaryrefslogtreecommitdiff
path: root/src/lazyfree.c
diff options
context:
space:
mode:
authorzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2018-07-31 12:07:57 +0800
committerzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2018-07-31 12:07:57 +0800
commitfddeeae724bec1a8e1a3dbb2f18e608b79c2ddfc (patch)
tree4cc45646573335a2688be99e0bdbb18e301cb5c1 /src/lazyfree.c
parentfd174cca23ede115ff71b379f10b407cfb54d3ad (diff)
downloadredis-fddeeae724bec1a8e1a3dbb2f18e608b79c2ddfc.tar.gz
refactor dbOverwrite to make lazyfree work
Diffstat (limited to 'src/lazyfree.c')
-rw-r--r--src/lazyfree.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lazyfree.c b/src/lazyfree.c
index ac8a6bee9..3d3159c90 100644
--- a/src/lazyfree.c
+++ b/src/lazyfree.c
@@ -90,6 +90,17 @@ int dbAsyncDelete(redisDb *db, robj *key) {
}
}
+/* Free an object, if the object is huge enough, free it in async way. */
+void freeObjAsync(robj *o) {
+ size_t free_effort = lazyfreeGetFreeEffort(o);
+ if (free_effort > LAZYFREE_THRESHOLD && o->refcount == 1) {
+ atomicIncr(lazyfree_objects,1);
+ bioCreateBackgroundJob(BIO_LAZY_FREE,o,NULL,NULL);
+ } else {
+ decrRefCount(o);
+ }
+}
+
/* Empty a Redis DB asynchronously. What the function does actually is to
* create a new empty set of hash tables and scheduling the old ones for
* lazy freeing. */