i new redis therefore don't know more complex technicalities. let me put scenario here: running 2 websites same server , wanted redis work on both. on searching, found can assigning different index different db on same server instance below:
//in first website (development) idatabase dbofdev=_conn.getdatabase(0); //in second website (production) idatabase dbofprod=_conn.getdatabase(1);
this ideal me since cache both database in same instance. bumped what's point of multiple redis databases? , how change between redis database? links says "use of multiple database in same server instance discouraged , deprecated". though these links try explain reason behind it, being beginner, still not able understand deep technical aspects.
can explain reason in simpler terms why using multiple redis db of same server instance discouraged. also, in simpler terms, how can manage caching of both websites on same server without above said approach?
how can manage caching of both websites on same server without above said approach?
you can use different key tag each website. say, name 2 websites a
, b
. keys of website a
, give each key prefix(key tag): a:
. on other hand, give each key website b
prefix: b:
. in way, can have unique key namespace each website.
set a:key1 val1 set a:key2 val2 lpush b:key1 1 sadd b:key2 val
can explain reason in simpler terms why using multiple redis db of same server instance discouraged.
afaik, multiple databases not discouraged , deprecated. it's method isolated key namespaces different applications.
redis single-threaded, compared multiple databases, multiple redis instances can take advantage of multiple cores. if have multiple databases in 1 redis instance, can still use 1 core.
redis fast, , bottleneck network bandwidth, not cpu. cannot gain using multiple redis instances. however, if 1 of application needs slow commands on redis, , don't want block other applications, can have separate redis instance slow application, , have redis instance other fast applications.
Comments
Post a Comment