Post on 02-Jul-2015
description
PERSISTING
DATAIt's literally going to kill me
Brian Best - github.com/brianbest
REDISIn memory database
system
THE GOOD
• Set my server up as git
remote. No more
cyberduck.
PROBLEMS
• Installation guilds suck
• Documentation for node module sketchy
• Sidetracked
SOLUTION
LAST NIGHT
MAKE THE CLIENT DO
ITThe server can stay on the beach
socket.on("chat message", function(msg){
//Print message to db
client.rpush('mes1', msg, redis.print);
io.emit('chat message', msg);
});
client.lrange(['mes1',0,-1], function (err, reply) {
io.emit('past messages', reply);
}, redis.print);
INDEX.JS (SERVER)
Capture Messages - Save to DB
Send Messages On Connection As Array
socket.on('past messages', function(msg){
pastPast(msg);
});
function pastPast(msg){
var messages = msg;
for(var i = 0; i < messages.length; i++){
$('#msg_area').prepend($('<p>').text(messages[i]));
}
}
PURE.JS (CLIENT)
Catch array from DB
NOW WHAT
• Data needs to save to
disk
• UI needs help
I'M FLYING AWAY
FROM YOU PEOPLE
But more on that next week