Nodejs - Redis - Can't find key

I have two Nodejs apps that should use the same Redis database.

  • The first app (A) stores the Data with lpush :

    database.lpush('messages', JSON.stringify(data), function(err, reply) { if(err) { console.log(err); } console.log(reply); });

  • The second app (B) dumps the same key (list) with lrange :

    database.lrange('messages', 0, -1, function(err, message) { if(err) { console.log(err); } database.emit('message', messages); });

But for some reason this doen't work. When (B) runs, I get an error message because lrange can't find 'messages'. Here's the error I get :

/node_modules/redis/index.js:523
            throw err;
                  ^
ReferenceError: messages is not defined
...

Can anyone help me on this ? Thanks in advance !

Edit : The code in this post doesn't seem to display normally. I'm not sure why.