I am trying to create a foreign table with redis_fdw. I used the below syntax
CREATE FOREIGN TABLE redis_db0 (key text, value text) SERVER redis_server OPTIONS (database '0');
Can anyone explain me the numeric parameter 0 that has been passed inside OPTIONS?
Redis has multiple numbered "databases" inside a single instance. The parameter you're referring to is to use database '0', which is also the default when you don't specify it (in Redis at least).
You can read more about it here , but basically just don't change it unless you have to.
default is use database '0',but you can change the default from source file networking.c ,method: client *createClient(int fd), this statements:selectDb(c,0);
you can change 0 to you wanted number,but it should <= server.dbnum
client *createClient(int fd) {
client *c = zmalloc(sizeof(client));
//some code ignored
selectDb(c,0);//at here,select you want number
this select 3
command in client invoke this method too
int selectDb(client *c, int id) {
if (id < 0 || id >= server.dbnum)
return C_ERR;
c->db = &server.db[id];
return C_OK;
}
and then if you type get
,it will execute
robj *lookupKeyReadOrReply(client *c, robj *key, robj *reply) {
robj *o = lookupKeyRead(c->db, key);//loopup the client database
if (!o) addReply(c,reply);
return o;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.