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
I am encoding an 8-byte key and passing it as a Buffer object to the mocked ioredis. While writing tests, I encountered this issue with IDs that encoded to different buffers but overwrite the same key on the fake server.
Redis server do overwrite the key, thankfully (^_^)
Here's a code to reproduce this issue:
constFakeRedis=require('ioredis-mock')functionid2Buffer(id){// expect 32 u intconstbuffer=Buffer.alloc(8);buffer.write('#:');buffer.writeUIntLE(id,2,6);// Supports up to 48 bits of accuracy.returnbuffer;}constredis=newFakeRedis();constid1=3294967294;constid2=id1+1;// works as excpected if changed to 2 or to -127 (other negatives numbers seens to also be in the same 'range' that cause the conflict)const[idBuf1,idBuf2]=[id2Buffer(id1),id2Buffer(id2)];(async()=>{awaitredis.set(idBuf1,'a');awaitredis.set(idBuf2,'b');constr1=awaitredis.get(idBuf1);constr2=awaitredis.get(idBuf2);console.log({ r1, r2 });// prints { r1: 'b', r2: 'b' } instead of { r1: 'a', r2: 'b' }constkeys=awaitredis.keys('*');console.log(keys);// prints just one key})();
The text was updated successfully, but these errors were encountered:
I am encoding an 8-byte key and passing it as a Buffer object to the mocked ioredis. While writing tests, I encountered this issue with IDs that encoded to different buffers but overwrite the same key on the fake server.
Redis server do overwrite the key, thankfully (^_^)
Here's a code to reproduce this issue:
The text was updated successfully, but these errors were encountered: