1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-03 04:01:40 +03:00
Files
2021-12-07 11:01:42 -05:00

28 lines
762 B
JavaScript

import { createClient } from 'redis-v3';
import { once } from 'events';
import { promisify } from 'util';
export default async (host, { randomString }) => {
const client = createClient({ host }),
setAsync = promisify(client.set).bind(client),
getAsync = promisify(client.get).bind(client),
delAsync = promisify(client.del).bind(client),
quitAsync = promisify(client.quit).bind(client);
await once(client, 'connect');
return {
benchmark() {
return Promise.all([
setAsync(randomString, randomString),
getAsync(randomString),
delAsync(randomString)
]);
},
teardown() {
return quitAsync();
}
};
};