<commit_before>var promise = require( 'bluebird' );
var romis = require( 'romis' );
var fs = require( 'fs' );
var EventEmitter = require( 'events' ).EventEmitter;

module.exports = storeRedis;

var ROOM_DOES_NOT_EXIST = promise.reject( 'There is no room by that id' );
ROOM_DOES_NOT_EXIST.catch( function() {} ); // this is to ensure there isnt a logged error

/**
 * storeRedis is used to store data in memory on one process. This is not ideal
 * for clustered servers as each process may have different data. Use another
 * memory store if your server is clustered however use this memory store just
 * to get up and running fast or if your server is not clustered.
 *
 * @param {redis} redis You should pass a redis client that will be used to write
 *                      to redis with.
 * @return {storeRedis} An new instance of storeRedis
 */
function storeRedis( redis ) {

	if( !( this instanceof storeRedis ) )
		return new storeRedis( redis );

	this.redis = romis.fromRedis( redis );

	this.redis.on( 'message', function( channel, message ) {

		message = JSON.parse( message );
		
		this.emit( message.roomID, message );
	}.bind( this ));
}

var p = storeRedis.prototype = new EventEmitter();<commit_msg>Fixed an issue where potentially all stores would emit when one store did<commit_after>var promise = require( 'bluebird' );
var romis = require( 'romis' );
var fs = require( 'fs' );
var EventEmitter = require( 'events' ).EventEmitter;

module.exports = storeRedis;

var ROOM_DOES_NOT_EXIST = promise.reject( 'There is no room by that id' );
ROOM_DOES_NOT_EXIST.catch( function() {} ); // this is to ensure there isnt a logged error

/**
 * storeRedis is used to store data in memory on one process. This is not ideal
 * for clustered servers as each process may have different data. Use another
 * memory store if your server is clustered however use this memory store just
 * to get up and running fast or if your server is not clustered.
 *
 * @param {redis} redis You should pass a redis client that will be used to write
 *                      to redis with.
 * @return {storeRedis} An new instance of storeRedis
 */
function storeRedis( redis ) {

	if( !( this instanceof storeRedis ) )
		return new storeRedis( redis );

	EventEmitter.call( this );

	this.redis = romis.fromRedis( redis );

	this.redis.on( 'message', function( channel, message ) {

		message = JSON.parse( message );
		
		this.emit( message.roomID, message );
	}.bind( this ));
}

var p = storeRedis.prototype = Object.create( EventEmitter.prototype );
{'fraction_non_alphanumeric': 0.09827044025157233, 'fraction_numerical': 0.0, 'mean_word_length': 3.6783088235294117, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4162384', 'n_tokens_mistral': 778, 'n_tokens_neox': 751, 'n_words': 313}