node redis - Posted on April Sun 26th 5:09 AM (Never Expires) - Format: javascript - This is a modified post titled "node redis". - See newer version(s) of this paste titled "radis node"
  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.     var player = {};
  20.     player.player_id = 'name';
  21.     player.room_id = q.id;
  22.     redisClient.hset('player_' + room_key, id, JSON.stringify(player), function (err, reply) {
  23.         console.log('playereded', err, reply);
  24.     });
  25. }

New Paste

Paste Options

Recent Pastes

9 days ago

EARN PAYPAL IN A

11 days ago

QUICK CASH VIA

11 days ago

ATM cloned cards

11 days ago

ATM cloned cards

11 days ago

ATM cloned cards

11 days ago

ATM cloned cards

17 days ago

A MONEY MAKING B

17 days ago

A MONEY MAKING B

17 days ago

A MONEY MAKING B

17 days ago

A MONEY MAKING B