function inrcCache(key) { return new Promise((resv, rej) => { client.incr(key, (err, res) => { resv(1); }); }) }
save(cb) { if (this.id) { this.update(cb); } else { db.incr('user:ids', (err, id) => { if (err) return cb(err); this.id = id; this.hashPassword((err) => { if (err) return cb(err); this.update(cb); }); }); } }
client.incr('user:ids', function (err, id) { if(err) return fn(err); user.id = id; thisUser.update(fn); })
// redisClient.set('REDIS_KEY', '0'); app.get('/', (req, res) => { redisClient.incr('REDIS_KEY'); redisClient.get('REDIS_KEY', (err, reply) => { res.send("<html><head><title>Page" + "</title><head><body><h1>Our Redis and Express Web Application</h1>" + "Redis count: " + reply + "</body></html>"); res.end(); }); });
redisClient.incr(key, function (err, ret) { if (err) return next(err); if (ret > limit) return next(utils.outOfRateLimitError()); next(); });
// create a server http .createServer((req, res) => { // increment the visit counter client.incr('visits', (err, reply) => { if (err) { console.log(err); res.status(500).send(err.message); return; } res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(`Visitor number: ${reply}\n`); }); }) .listen(8080);
app.post('/api/increment-page-views', function (req, res) { client.incr('page.views', function (err, reply) { if (err) { res.status(500).send({error: String(err)}); } else { res.json({'pageviews': reply}); } }); });
db.incr('user:ids', function(err, id){ if (err) return fn(err); user.id = id; user.hashPassword(function(err){ if (err) return fn(err); user.update(fn); }); });
static async getCode() { return await client.incr( 'short' ); }
save(cb) { if (this.id) { this.update(cb); } else { db.incr('user:ids', (err, id) => { if (err) return cb(err); this.id = id; this.hashPassword((err) => { if (err) return cb(err); this.update(cb); }); }); } }
save(cb) { if (this.id) { this.update(cb); } else { db.incr('user:ids', (err, id) => { if (err) return cb(err); this.id = id; this.hashPassword((err) => { if (err) return cb(err); this.update(cb); }); }); } }
save(cb) { if (this.id) { this.update(cb); } else { db.incr('user:ids', (err, id) => { if (err) return cb(err); this.id = id; this.hashPassword((err) => { if (err) return cb(err); this.update(cb); }); }); } }