pro-grid/pro-grid — pull request #90 by ridhoq (2014-03-02 01:21:47+00:00)
Title: Adds persistence using Redis

Install redis here: http://redis.io/download. You'll need to start the redis server before you run the app. Everything should be configured to work out of the box atm, but we may need to configure it so that it will work on heroku.

So this is how I chose to integrate redis:
When instantiating the Grid object, we check to see if we've previously saved grid state. This is done by checking a a pre-determined key(gridSaved). If we do find that the key has been set, then we load the grid by constructing a "multi-get" query (http://redis.io/commands/mget) and set the data returned in the appropriate position of the grid. If not, then we set the key as every future click will now be stored in redis.

When processing a click, we now do a couple of things in series using the waterfall function provided by the async library(https://github.com/caolan/async#waterfall). This is the order of events on click:
1. Update the Grid object locally.
2. Emit a message to the client informing it about the updated Grid.
3. Update redis

We still need unit tests for all this stuff. Maybe the homies @austinpray @DarrenCattle @alexwforsythe could write some :100: :thumbsup: