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

24 hours ago

dir

10 days ago

Untitled

13 days ago

Untitled

19 days ago

Untitled

68 days ago

Untitled

68 days ago

Untitled

68 days ago

Untitled

68 days ago

Untitled

74 days ago

radis node

74 days ago

node redis