From f4f06efccc4064fa0f7f7f16098de746fa0e5b69 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 7 May 2010 11:40:26 +0200 Subject: [PATCH] don't load value from VM for EXISTS --- TODO | 1 - redis.c | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index bdbe7974..331c560a 100644 --- a/TODO +++ b/TODO @@ -15,7 +15,6 @@ Virtual Memory sub-TODO: * Check if the page selection algorithm is working well * Divide swappability of objects by refcount * Use multiple open FDs against the VM file, one for thread. -* EXISTS should avoid loading the object if possible without making the code too specialized. * vm-min-age option * Make sure objects loaded from the VM are specially encoded when possible. * Check what happens performance-wise if instead to create threads again and again the same threads are reused forever. Note: this requires a way to disable this clients in the child, but waiting for empty new jobs queue can be enough. diff --git a/redis.c b/redis.c index c22a1c8c..19f431cf 100644 --- a/redis.c +++ b/redis.c @@ -4343,7 +4343,12 @@ static void delCommand(redisClient *c) { } static void existsCommand(redisClient *c) { - addReply(c,lookupKeyRead(c->db,c->argv[1]) ? shared.cone : shared.czero); + expireIfNeeded(c->db,c->argv[1]); + if (dictFind(c->db->dict,c->argv[1])) { + addReply(c, shared.cone); + } else { + addReply(c, shared.czero); + } } static void selectCommand(redisClient *c) {