-
-
Notifications
You must be signed in to change notification settings - Fork 48
Closed
Description
I started using the library and realized that it seems not working properly on concurrent requests.
I tested several scenarios, and it seems only to return the last command with the first result.
import { connect } from 'https://denopkg.com/keroxp/deno-redis/redis.ts';
const config = { hostname: '127.0.0.1', port: 6379 };
const keys = ['a', 'b', 'c'];
(async () => {
const redis = await connect(config);
for (const key of keys) {
await redis.set(key, key);
}
})();// in series, it works fine
(async () => {
const redis = await connect(config);
for (const key of keys) {
const val = await redis.get(key);
console.log({ key, val });
}
/**
* { key: "a", val: "a" }
* { key: "b", val: "b" }
* { key: "c", val: "c" }
*/
})();// get a wrong result
(async () => {
const redis = await connect(config);
for (const key of keys) {
redis.get(key).then(val => {
console.log({ key, val });
});
}
/**
* wrong output and only one
* { key: "c", val: "a" }
*/
})();// no responses
(async () => {
const redis = await connect(config);
const values = await Promise.all(keys.map(key => redis.get(key)));
console.log(values); // never reached
})();// get a wrong result
(async () => {
const redis = await connect(config);
redis.get(keys[0]);
const values = await redis.keys('*');
console.log(values); // a
})();Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels