Skip to content

Commit 586d3cc

Browse files
9banyPatrickJS
authored andcommitted
Rename redisDb to serverDb (valkey-io#156)
A task of valkey-io#144. Signed-off-by: 0del <[email protected]>
1 parent c9020d2 commit 586d3cc

16 files changed

+130
-130
lines changed

src/aof.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,7 @@ int rewriteAppendOnlyFileRio(rio *aof) {
22602260

22612261
for (j = 0; j < server.dbnum; j++) {
22622262
char selectcmd[] = "*2\r\n$6\r\nSELECT\r\n";
2263-
redisDb *db = server.db + j;
2263+
serverDb *db = server.db + j;
22642264
if (kvstoreSize(db->keys) == 0) continue;
22652265

22662266
/* SELECT the new DB */

src/blocked.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ static blocking_type getBlockedTypeByType(int type) {
453453
* made by a script or in the context of MULTI/EXEC.
454454
*
455455
* The list will be finally processed by handleClientsBlockedOnKeys() */
456-
static void signalKeyAsReadyLogic(redisDb *db, robj *key, int type, int deleted) {
456+
static void signalKeyAsReadyLogic(serverDb *db, robj *key, int type, int deleted) {
457457
readyList *rl;
458458

459459
/* Quick returns. */
@@ -548,11 +548,11 @@ static void releaseBlockedEntry(client *c, dictEntry *de, int remove_key) {
548548
dictDelete(c->bstate.keys, key);
549549
}
550550

551-
void signalKeyAsReady(redisDb *db, robj *key, int type) {
551+
void signalKeyAsReady(serverDb *db, robj *key, int type) {
552552
signalKeyAsReadyLogic(db, key, type, 0);
553553
}
554554

555-
void signalDeletedKeyAsReady(redisDb *db, robj *key, int type) {
555+
void signalDeletedKeyAsReady(serverDb *db, robj *key, int type) {
556556
signalKeyAsReadyLogic(db, key, type, 1);
557557
}
558558

src/db.c

+47-47
Large diffs are not rendered by default.

src/debug.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void mixStringObjectDigest(unsigned char *digest, robj *o) {
142142
* Note that this function does not reset the initial 'digest' passed, it
143143
* will continue mixing this object digest to anything that was already
144144
* present. */
145-
void xorObjectDigest(redisDb *db, robj *keyobj, unsigned char *digest, robj *o) {
145+
void xorObjectDigest(serverDb *db, robj *keyobj, unsigned char *digest, robj *o) {
146146
uint32_t aux = htonl(o->type);
147147
mixDigest(digest,&aux,sizeof(aux));
148148
long long expiretime = getExpire(db,keyobj);
@@ -288,7 +288,7 @@ void computeDatasetDigest(unsigned char *final) {
288288
memset(final,0,20); /* Start with a clean result */
289289

290290
for (j = 0; j < server.dbnum; j++) {
291-
redisDb *db = server.db+j;
291+
serverDb *db = server.db+j;
292292
if (kvstoreSize(db->keys) == 0)
293293
continue;
294294
kvstoreIterator *kvs_it = kvstoreIteratorInit(db->keys);

src/defrag.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ void activeDefragQuickListNodes(quicklist *ql) {
349349
/* when the value has lots of elements, we want to handle it later and not as
350350
* part of the main dictionary scan. this is needed in order to prevent latency
351351
* spikes when handling large items */
352-
void defragLater(redisDb *db, dictEntry *kde) {
352+
void defragLater(serverDb *db, dictEntry *kde) {
353353
sds key = sdsdup(dictGetKey(kde));
354354
listAddNodeTail(db->defrag_later, key);
355355
}
@@ -449,7 +449,7 @@ void scanLaterHash(robj *ob, unsigned long *cursor) {
449449
*cursor = dictScanDefrag(d, *cursor, scanCallbackCountScanned, &defragfns, NULL);
450450
}
451451

452-
void defragQuicklist(redisDb *db, dictEntry *kde) {
452+
void defragQuicklist(serverDb *db, dictEntry *kde) {
453453
robj *ob = dictGetVal(kde);
454454
quicklist *ql = ob->ptr, *newql;
455455
serverAssert(ob->type == OBJ_LIST && ob->encoding == OBJ_ENCODING_QUICKLIST);
@@ -461,7 +461,7 @@ void defragQuicklist(redisDb *db, dictEntry *kde) {
461461
activeDefragQuickListNodes(ql);
462462
}
463463

464-
void defragZsetSkiplist(redisDb *db, dictEntry *kde) {
464+
void defragZsetSkiplist(serverDb *db, dictEntry *kde) {
465465
robj *ob = dictGetVal(kde);
466466
zset *zs = (zset*)ob->ptr;
467467
zset *newzs;
@@ -490,7 +490,7 @@ void defragZsetSkiplist(redisDb *db, dictEntry *kde) {
490490
zs->dict = newdict;
491491
}
492492

493-
void defragHash(redisDb *db, dictEntry *kde) {
493+
void defragHash(serverDb *db, dictEntry *kde) {
494494
robj *ob = dictGetVal(kde);
495495
dict *d, *newd;
496496
serverAssert(ob->type == OBJ_HASH && ob->encoding == OBJ_ENCODING_HT);
@@ -504,7 +504,7 @@ void defragHash(redisDb *db, dictEntry *kde) {
504504
ob->ptr = newd;
505505
}
506506

507-
void defragSet(redisDb *db, dictEntry *kde) {
507+
void defragSet(serverDb *db, dictEntry *kde) {
508508
robj *ob = dictGetVal(kde);
509509
dict *d, *newd;
510510
serverAssert(ob->type == OBJ_SET && ob->encoding == OBJ_ENCODING_HT);
@@ -657,7 +657,7 @@ void* defragStreamConsumerGroup(raxIterator *ri, void *privdata) {
657657
return NULL;
658658
}
659659

660-
void defragStream(redisDb *db, dictEntry *kde) {
660+
void defragStream(serverDb *db, dictEntry *kde) {
661661
robj *ob = dictGetVal(kde);
662662
serverAssert(ob->type == OBJ_STREAM && ob->encoding == OBJ_ENCODING_STREAM);
663663
stream *s = ob->ptr, *news;
@@ -681,7 +681,7 @@ void defragStream(redisDb *db, dictEntry *kde) {
681681
/* Defrag a module key. This is either done immediately or scheduled
682682
* for later. Returns then number of pointers defragged.
683683
*/
684-
void defragModule(redisDb *db, dictEntry *kde) {
684+
void defragModule(serverDb *db, dictEntry *kde) {
685685
robj *obj = dictGetVal(kde);
686686
serverAssert(obj->type == OBJ_MODULE);
687687

@@ -696,7 +696,7 @@ void defragKey(defragCtx *ctx, dictEntry *de) {
696696
robj *newob, *ob;
697697
unsigned char *newzl;
698698
sds newsds;
699-
redisDb *db = ctx->privdata;
699+
serverDb *db = ctx->privdata;
700700
int slot = ctx->slot;
701701
/* Try to defrag the key name. */
702702
newsds = activeDefragSds(keysds);
@@ -884,7 +884,7 @@ static sds defrag_later_current_key = NULL;
884884
static unsigned long defrag_later_cursor = 0;
885885

886886
/* returns 0 if no more work needs to be been done, and 1 if time is up and more work is needed. */
887-
int defragLaterStep(redisDb *db, int slot, long long endtime) {
887+
int defragLaterStep(serverDb *db, int slot, long long endtime) {
888888
unsigned int iterations = 0;
889889
unsigned long long prev_defragged = server.stat_active_defrag_hits;
890890
unsigned long long prev_scanned = server.stat_active_defrag_scanned;
@@ -993,7 +993,7 @@ void activeDefragCycle(void) {
993993
static int defrag_later_item_in_progress = 0;
994994
static int defrag_stage = 0;
995995
static unsigned long defrag_cursor = 0;
996-
static redisDb *db = NULL;
996+
static serverDb *db = NULL;
997997
static long long start_scan, start_stat;
998998
unsigned int iterations = 0;
999999
unsigned long long prev_defragged = server.stat_active_defrag_hits;

src/evict.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void evictionPoolAlloc(void) {
143143
* We insert keys on place in ascending order, so keys with the smaller
144144
* idle time are on the left, and keys with the higher idle time on the
145145
* right. */
146-
int evictionPoolPopulate(redisDb *db, kvstore *samplekvs, struct evictionPoolEntry *pool) {
146+
int evictionPoolPopulate(serverDb *db, kvstore *samplekvs, struct evictionPoolEntry *pool) {
147147
int j, k, count;
148148
dictEntry *samples[server.maxmemory_samples];
149149

@@ -579,7 +579,7 @@ int performEvictions(void) {
579579
static unsigned int next_db = 0;
580580
sds bestkey = NULL;
581581
int bestdbid;
582-
redisDb *db;
582+
serverDb *db;
583583
dictEntry *de;
584584

585585
if (server.maxmemory_policy & (MAXMEMORY_FLAG_LRU|MAXMEMORY_FLAG_LFU) ||

src/expire.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static double avg_ttl_factor[16] = {0.98, 0.9604, 0.941192, 0.922368, 0.903921,
5555
*
5656
* The parameter 'now' is the current time in milliseconds as is passed
5757
* to the function to avoid too many gettimeofday() syscalls. */
58-
int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) {
58+
int activeExpireCycleTryExpire(serverDb *db, dictEntry *de, long long now) {
5959
long long t = dictGetSignedIntegerVal(de);
6060
if (now > t) {
6161
enterExecutionUnit(1, 0);
@@ -118,7 +118,7 @@ int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) {
118118

119119
/* Data used by the expire dict scan callback. */
120120
typedef struct {
121-
redisDb *db;
121+
serverDb *db;
122122
long long now;
123123
unsigned long sampled; /* num keys checked */
124124
unsigned long expired; /* num keys expired */
@@ -242,7 +242,7 @@ void activeExpireCycle(int type) {
242242
data.ttl_sum = 0;
243243
data.ttl_samples = 0;
244244

245-
redisDb *db = server.db+(current_db % server.dbnum);
245+
serverDb *db = server.db+(current_db % server.dbnum);
246246
data.db = db;
247247

248248
int db_done = 0; /* The scan of the current DB is done? */
@@ -429,7 +429,7 @@ void expireSlaveKeys(void) {
429429
int dbid = 0;
430430
while(dbids && dbid < server.dbnum) {
431431
if ((dbids & 1) != 0) {
432-
redisDb *db = server.db+dbid;
432+
serverDb *db = server.db+dbid;
433433
dictEntry *expire = dbFindExpires(db, keyname);
434434
int expired = 0;
435435

@@ -474,7 +474,7 @@ void expireSlaveKeys(void) {
474474

475475
/* Track keys that received an EXPIRE or similar command in the context
476476
* of a writable slave. */
477-
void rememberSlaveKeyWithExpire(redisDb *db, robj *key) {
477+
void rememberSlaveKeyWithExpire(serverDb *db, robj *key) {
478478
if (slaveKeysWithExpire == NULL) {
479479
static dictType dt = {
480480
dictSdsHash, /* hash function */

src/lazyfree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void freeObjAsync(robj *key, robj *obj, int dbid) {
185185
/* Empty a Redis DB asynchronously. What the function does actually is to
186186
* create a new empty set of hash tables and scheduling the old ones for
187187
* lazy freeing. */
188-
void emptyDbAsync(redisDb *db) {
188+
void emptyDbAsync(serverDb *db) {
189189
int slot_count_bits = 0;
190190
int flags = KVSTORE_ALLOCATE_DICTS_ON_DEMAND;
191191
if (server.cluster_enabled) {

src/module.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ typedef struct RedisModuleCtx RedisModuleCtx;
189189
/* This represents a Redis key opened with RM_OpenKey(). */
190190
struct RedisModuleKey {
191191
RedisModuleCtx *ctx;
192-
redisDb *db;
192+
serverDb *db;
193193
robj *key; /* Key name object. */
194194
robj *value; /* Value object, or NULL if the key was not found. */
195195
void *iter; /* Iterator. */

src/multi.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void execCommand(client *c) {
274274
typedef struct watchedKey {
275275
listNode node;
276276
robj *key;
277-
redisDb *db;
277+
serverDb *db;
278278
client *client;
279279
unsigned expired:1; /* Flag that we're watching an already expired key. */
280280
} watchedKey;
@@ -377,7 +377,7 @@ int isWatchedKeyExpired(client *c) {
377377

378378
/* "Touch" a key, so that if this key is being WATCHed by some client the
379379
* next EXEC will fail. */
380-
void touchWatchedKey(redisDb *db, robj *key) {
380+
void touchWatchedKey(serverDb *db, robj *key) {
381381
list *clients;
382382
listIter li;
383383
listNode *ln;
@@ -425,7 +425,7 @@ void touchWatchedKey(redisDb *db, robj *key) {
425425
* replaced_with: for SWAPDB, the WATCH should be invalidated if
426426
* the key exists in either of them, and skipped only if it
427427
* doesn't exist in both. */
428-
void touchAllWatchedKeysInDb(redisDb *emptied, redisDb *replaced_with) {
428+
void touchAllWatchedKeysInDb(serverDb *emptied, serverDb *replaced_with) {
429429
listIter li;
430430
listNode *ln;
431431
dictEntry *de;

src/object.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ struct serverMemOverhead *getMemoryOverheadData(void) {
12451245
mem_total+=mh->functions_caches;
12461246

12471247
for (j = 0; j < server.dbnum; j++) {
1248-
redisDb *db = server.db+j;
1248+
serverDb *db = server.db+j;
12491249
if (!kvstoreNumAllocatedDicts(db->keys)) continue;
12501250

12511251
unsigned long long keyscount = kvstoreSize(db->keys);

src/rdb.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ ssize_t rdbSaveDb(rio *rdb, int dbid, int rdbflags, long *key_counter) {
13051305
static long long info_updated_time = 0;
13061306
char *pname = (rdbflags & RDBFLAGS_AOF_PREAMBLE) ? "AOF rewrite" : "RDB";
13071307

1308-
redisDb *db = server.db + dbid;
1308+
serverDb *db = server.db + dbid;
13091309
unsigned long long int db_size = kvstoreSize(db->keys);
13101310
if (db_size == 0) return 0;
13111311

@@ -3033,7 +3033,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin
30333033
int type, rdbver;
30343034
uint64_t db_size = 0, expires_size = 0;
30353035
int should_expand_db = 0;
3036-
redisDb *db = rdb_loading_ctx->dbarray+0;
3036+
serverDb *db = rdb_loading_ctx->dbarray+0;
30373037
char buf[1024];
30383038
int error;
30393039
long long empty_keys_skipped = 0;

src/replication.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1840,13 +1840,13 @@ static int useDisklessLoad(void) {
18401840
/* Helper function for readSyncBulkPayload() to initialize tempDb
18411841
* before socket-loading the new db from master. The tempDb may be populated
18421842
* by swapMainDbWithTempDb or freed by disklessLoadDiscardTempDb later. */
1843-
redisDb *disklessLoadInitTempDb(void) {
1843+
serverDb *disklessLoadInitTempDb(void) {
18441844
return initTempDb();
18451845
}
18461846

18471847
/* Helper function for readSyncBulkPayload() to discard our tempDb
18481848
* when the loading succeeded or failed. */
1849-
void disklessLoadDiscardTempDb(redisDb *tempDb) {
1849+
void disklessLoadDiscardTempDb(serverDb *tempDb) {
18501850
discardTempDb(tempDb, replicationEmptyDbCallback);
18511851
}
18521852

@@ -1870,7 +1870,7 @@ void readSyncBulkPayload(connection *conn) {
18701870
char buf[PROTO_IOBUF_LEN];
18711871
ssize_t nread, readlen, nwritten;
18721872
int use_diskless_load = useDisklessLoad();
1873-
redisDb *diskless_load_tempDb = NULL;
1873+
serverDb *diskless_load_tempDb = NULL;
18741874
functionsLibCtx* temp_functions_lib_ctx = NULL;
18751875
int empty_db_flags = server.repl_slave_lazy_flush ? EMPTYDB_ASYNC :
18761876
EMPTYDB_NO_FLAGS;
@@ -2088,7 +2088,7 @@ void readSyncBulkPayload(connection *conn) {
20882088
rdbSaveInfo rsi = RDB_SAVE_INFO_INIT;
20892089
if (use_diskless_load) {
20902090
rio rdb;
2091-
redisDb *dbarray;
2091+
serverDb *dbarray;
20922092
functionsLibCtx* functions_lib_ctx;
20932093
int asyncLoading = 0;
20942094

src/server.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ void databasesCron(void) {
10821082
if (dbs_per_call > server.dbnum) dbs_per_call = server.dbnum;
10831083

10841084
for (j = 0; j < dbs_per_call; j++) {
1085-
redisDb *db = &server.db[resize_db % server.dbnum];
1085+
serverDb *db = &server.db[resize_db % server.dbnum];
10861086
kvstoreTryResizeDicts(db->keys, CRON_DICTS_PER_DB);
10871087
kvstoreTryResizeDicts(db->expires, CRON_DICTS_PER_DB);
10881088
resize_db++;
@@ -1092,7 +1092,7 @@ void databasesCron(void) {
10921092
if (server.activerehashing) {
10931093
uint64_t elapsed_us = 0;
10941094
for (j = 0; j < dbs_per_call; j++) {
1095-
redisDb *db = &server.db[rehash_db % server.dbnum];
1095+
serverDb *db = &server.db[rehash_db % server.dbnum];
10961096
elapsed_us += kvstoreIncrementallyRehash(db->keys, INCREMENTAL_REHASHING_THRESHOLD_US - elapsed_us);
10971097
if (elapsed_us >= INCREMENTAL_REHASHING_THRESHOLD_US)
10981098
break;
@@ -2655,7 +2655,7 @@ void initServer(void) {
26552655
strerror(errno));
26562656
exit(1);
26572657
}
2658-
server.db = zmalloc(sizeof(redisDb)*server.dbnum);
2658+
server.db = zmalloc(sizeof(server)*server.dbnum);
26592659

26602660
/* Create the Redis databases, and initialize other internal state. */
26612661
int slot_count_bits = 0;

0 commit comments

Comments
 (0)