SHARE
TWEET

Untitled

a guest Apr 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const redis = require('redis');
  3.  
  4. const app = express();
  5. const client = redis.createClient({
  6.     host: 'redis-server',
  7.     port: 6379
  8. });
  9. client.set('visits', 0);
  10.  
  11. app.get('/', (req, res) => {
  12.   client.get('visits', (err, visits) => {
  13.     res.send('Number of visits is ' + visits);
  14.     client.set('visits', parseInt(visits) + 1);
  15.   });
  16. });
  17.  
  18. app.listen(8081, () => {
  19.   console.log('Listening on port 8081');
  20. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top