From fddeeae724bec1a8e1a3dbb2f18e608b79c2ddfc Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Tue, 31 Jul 2018 12:07:57 +0800 Subject: refactor dbOverwrite to make lazyfree work --- src/lazyfree.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lazyfree.c') 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. */ -- cgit v1.2.1