mem.js
655 Bytes
const cache = global.yoho.cache;
const data = require('./test.json');
const benchmark = require('./utils/benchmark');
const cachedSet = benchmark(cache.set, cache);
const cachedGet = benchmark(cache.get, cache);
async function benchmarkMem(req, res) {
console.log('memcache write');
for (let i = 0; i < 100; i++) {
await cachedSet(`cache:${1}`, data);
}
console.log('memcache get');
for (let i = 0; i < 100; i++) {
let result = await cachedGet(`cache:${i}`);
if (result) {
console.log('memcached get');
}
}
res.json({code: 200, message: ''});
}
module.exports = benchmarkMem;