X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/67b0b41c879d01a35b1fcdab88b7e70f95a3232c..aa81e4d5f4b4d942b9340fd2d401e7795fa9fd1e:/src/redis.c diff --git a/src/redis.c b/src/redis.c index 2ca37a3b..65cf3ace 100644 --- a/src/redis.c +++ b/src/redis.c @@ -345,7 +345,7 @@ unsigned int dictEncObjHash(const void *key) { } } -/* Sets type */ +/* Sets type and diskstore negative caching hash table */ dictType setDictType = { dictEncObjHash, /* hash function */ NULL, /* key dup */ @@ -596,7 +596,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { } updateDictResizePolicy(); } - } else { + } else if (!server.ds_enabled) { /* If there is not a background saving in progress check if * we have to save now */ time_t now = time(NULL); @@ -769,7 +769,7 @@ void initServerConfig() { server.maxmemory_policy = REDIS_MAXMEMORY_VOLATILE_LRU; server.maxmemory_samples = 3; server.ds_enabled = 0; - server.ds_path = zstrdup("/tmp/redis.ds"); + server.ds_path = sdsnew("/tmp/redis.ds"); server.cache_max_memory = 64LL*1024*1024; /* 64 MB of RAM */ server.cache_blocked_clients = 0; server.hash_max_zipmap_entries = REDIS_HASH_MAX_ZIPMAP_ENTRIES; @@ -854,8 +854,10 @@ void initServer() { server.db[j].expires = dictCreate(&keyptrDictType,NULL); server.db[j].blocking_keys = dictCreate(&keylistDictType,NULL); server.db[j].watched_keys = dictCreate(&keylistDictType,NULL); - if (server.ds_enabled) + if (server.ds_enabled) { server.db[j].io_keys = dictCreate(&keylistDictType,NULL); + server.db[j].io_negcache = dictCreate(&setDictType,NULL); + } server.db[j].id = j; } server.pubsub_channels = dictCreate(&keylistDictType,NULL); @@ -1050,7 +1052,9 @@ int prepareForShutdown() { kill(server.bgsavechildpid,SIGKILL); rdbRemoveTempFile(server.bgsavechildpid); } - if (server.appendonly) { + if (server.ds_enabled) { + /* FIXME: flush all objects on disk */ + } else if (server.appendonly) { /* Append only file: fsync() the AOF and exit */ aof_fsync(server.appendfd); } else if (server.saveparamslen > 0) {