node redis - Posted on April Sun 26th 5:07 AM (Never Expires) - Format: javascript - See newer version(s) of this paste titled "node redis"
  1. function getOrDelete(q) {
  2.     let room_key = q.id + '_' + q.room;
  3.     redisClient.hgetall('player_' + room_key, function (err, data) {
  4.         var items = [];
  5.         for (i in data) {
  6.             let item = JSON.parse(data[i]);
  7.             if (Date.now() - item.last_seen > 100) {
  8.                 redisClient.hdel(room_key, i);
  9.             } else {
  10.                 items.push(item);
  11.             }
  12.         }
  13.  
  14.         console.log(items);
  15.     });
  16. }
  17. function add(q) {
  18.     let room_key = q.id + '_' + q.token;
  19.     redisClient.exists(room_key, function (err, reply) {
  20.         if (reply !== 1) {
  21.             return res.status(422).json({ errors: 'unknown' });
  22.         } else {
  23.             var player = {};
  24.             player.player_id = id;
  25.             player.room_id = req.id;
  26.             redisClient.hset('player_' + room_key, id, JSON.stringify(player), function (err, reply) {
  27.                 console.log('playereded', err, reply);
  28.             });
  29.         }
  30.     });
  31. }

New Paste

Paste Options

Recent Pastes

41 hours ago

All transfers

4 days ago

Cloned Cards pre

10 days ago

Cvv PayPal banks

11 days ago

Cloned card and

11 days ago

DO ALL TRANSFERS

18 days ago

Cloned Cards and

18 days ago

Cloned Cards and

18 days ago

AB Authentic Sel

18 days ago

AB Authentic Sel

51 days ago

Cloned Cards pre