You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@leibale The removal of the prefix option was a terrible idea. I am down grading because of it. Please rethink this and add it back.
Reacted by Siddharth VP, mabalashov, NeurAlch, Maxwell Lang, Andrea Roveroni, Yury Kozlov, Oleksandr Malovichko, William L, Drew Harris, Dmytro and 9 more
@leibale The prefix option was particularly useful when other libraries allowed you to provide a redis client as a substitute for their own (e.g bulljs). Thus, allowing you to prefix those libraries created keys. This implicitly allowed you to namespace their keys as well which normally would not be possible. It's something ioredis support out of the box
Reacted by ADEBISI Foluso A., Siddharth VP and Mykal Machon
@samypr100
We've decided to remove this feature because:
constPREFIX='prefix:';constclient=createClient({prefix: PREFIX});for(constkeyofclient.scanIterator('*')){// key is `prefix:${key}`awaitclient.get(key);// will run `GET prefix:prefix:${key}` instead of `GET prefix:${key}`awaitclient.get(key.substring(PREFIX.length));// works, but...}
Regarding bull - here is a quote from the PATTERNS.md file: "do not set a keyPrefix on the connection you create, use bull's built-in prefix feature if you need a key prefix"
/** * https://github.com/redis/node-redis/issues/1657#issuecomment-2873493460 */constcreateRedisDatabaseAssigner=async({ url }: {url: string})=>{constredisMain=(awaitcreateClient({// We use database 0 as a main database for test run id storage.database: 0,
url,}).connect())asRedisClientType;return{assignDatabase: async({ testRunId }: {testRunId: string})=>{letassignedDatabase=(awaitredisMain.get(`assigned-database:${testRunId}`,))
? Number(awaitredisMain.get(`assigned-database:${testRunId}`))
: null;letnewAssignedDatabase=false;if(!assignedDatabase){constlastDatabase=(awaitredisMain.get('last-database'))
? Number(awaitredisMain.get('last-database'))
: 0;// By default there are 16 databases (indexed from 0 to 15) and// you can navigate between them using select command.// Beware that this means that this concurrency control will break// if we run more than 16 tests concurrently.assignedDatabase=lastDatabase>14 ? 1 : lastDatabase+1;awaitredisMain.set('last-database',assignedDatabase);awaitredisMain.set(`assigned-database:${testRunId}`,assignedDatabase);newAssignedDatabase=true;}constredis=(awaitcreateClient({database: assignedDatabase,
url,}).connect())asRedisClientType;if(newAssignedDatabase){awaitredis.flushDb();}returnredis;},};};
I switched off of node-redis for ioredis because of this
Our use case required many processes to talk to the same db, each with isolated keys.
Yes, we lost redis time series support on ioredis, but it solves the massive headache which is to keep all the processes (which don't know about each other) have unique keyspacing
Reacted by matsoob, Mykal Machon, sergio-ferreira-jscrambler, Marek and Steve
Activity
leibale commentedon Sep 17, 2021
something like:
wmantly commentedon Jan 3, 2022
@leibale The removal of the
prefixoption was a terrible idea. I am down grading because of it. Please rethink this and add it back.samypr100 commentedon Jan 17, 2022
@leibale The prefix option was particularly useful when other libraries allowed you to provide a redis client as a substitute for their own (e.g bulljs). Thus, allowing you to prefix those libraries created keys. This implicitly allowed you to namespace their keys as well which normally would not be possible. It's something ioredis support out of the box
leibale commentedon Jan 17, 2022
@samypr100
We've decided to remove this feature because:
Regarding bull - here is a quote from the PATTERNS.md file: "do not set a
keyPrefixon the connection you create, use bull's built-in prefix feature if you need a key prefix"https://github.com/OptimalBits/bull/blob/16fdbe90a05ae2e2bcb134a550a97dc84dfe573e/lib/queue.js#L140
samypr100 commentedon Jan 17, 2022
Fair, thanks for the clarification. I'm lucky that most of my other dependencies take a prefix option at this time, so I'm okay for the time being :)
gajus commentedon May 12, 2025
Migrating from
ioredisto this is a major PITA, e.g. we used to useprefixoption to namespace our databases for integration tests.Now we need to figure out odd hacks to make it work.
gajus commentedon May 12, 2025
Had to come up with this monstrosity:
SamuelGaona commentedon Jul 7, 2025
+1
magidandrew commentedon Sep 10, 2025
I switched off of node-redis for ioredis because of this
Our use case required many processes to talk to the same db, each with isolated keys.
Yes, we lost redis time series support on ioredis, but it solves the massive headache which is to keep all the processes (which don't know about each other) have unique keyspacing
gajus commentedon Jul 3, 2026
Key prefixing is back.
mifi commentedon Aug 5, 2026
yea the option is now called
keyPrefix, just like in ioredis (but I think it gets ignored forsendCommandwhich is not the case in ioredis)