Skip to Content
Building Scalable Apps with Redis and Node.js
book

Building Scalable Apps with Redis and Node.js

by Joshua Johanan
September 2014
Intermediate to advanced
316 pages
7h 6m
English
Packt Publishing
Content preview from Building Scalable Apps with Redis and Node.js

Adding a new worker

We have one small problem at this point. As time goes on, more and more rooms will be created and more messages will accumulate. Eventually, we will run Redis out of memory. We are not being good Redis citizens. We need to remove our Redis data and will do this with a new worker.

Create a file named chat.js under the workers directory. Start the function with the following code:

var client = require('../redis').client,
  log = require('../middleware/log');

var delta = 60 * 60 * 1000 * 3; //10800000
var interval = 60 * 60 * 1000 * 2; //7200000

We include our Redis client and logger. Then, we set up our delta and interval. We will remove any room, chat, or user that has been inactive or was created 3 hours ago (10,800,000 milliseconds ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reactive Programming with Node.js

Reactive Programming with Node.js

Fernando Doglio
Node: Up and Running

Node: Up and Running

Tom Hughes-Croucher, Mike Wilson
Learn TypeScript 3 by Building Web Applications

Learn TypeScript 3 by Building Web Applications

Sebastien Dubois, Alexis Georges

Publisher Resources

ISBN: 9781783984480Supplemental Content