diff options
author | zhaozhao.zz <zhaozhao.zz@alibaba-inc.com> | 2018-07-31 12:07:57 +0800 |
---|---|---|
committer | zhaozhao.zz <zhaozhao.zz@alibaba-inc.com> | 2018-07-31 12:07:57 +0800 |
commit | fddeeae724bec1a8e1a3dbb2f18e608b79c2ddfc (patch) | |
tree | 4cc45646573335a2688be99e0bdbb18e301cb5c1 /src/lazyfree.c | |
parent | fd174cca23ede115ff71b379f10b407cfb54d3ad (diff) | |
download | redis-fddeeae724bec1a8e1a3dbb2f18e608b79c2ddfc.tar.gz |
refactor dbOverwrite to make lazyfree work
Diffstat (limited to 'src/lazyfree.c')
-rw-r--r-- | src/lazyfree.c | 11 |
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. */ |