How to persist data with Redis

14
PERSISTING DATA It's literally going to kill me Brian Best - github.com/brianbest

description

My week on redis

Transcript of How to persist data with Redis

Page 1: How to persist data with Redis

PERSISTING

DATAIt's literally going to kill me

Brian Best - github.com/brianbest

Page 2: How to persist data with Redis

REDISIn memory database

system

Page 3: How to persist data with Redis

THE GOOD

• Set my server up as git

remote. No more

cyberduck.

Page 4: How to persist data with Redis

PROBLEMS

• Installation guilds suck

• Documentation for node module sketchy

• Sidetracked

Page 5: How to persist data with Redis
Page 6: How to persist data with Redis
Page 7: How to persist data with Redis
Page 8: How to persist data with Redis

SOLUTION

Page 9: How to persist data with Redis

LAST NIGHT

Page 10: How to persist data with Redis

MAKE THE CLIENT DO

ITThe server can stay on the beach

Page 11: How to persist data with Redis

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

Page 12: How to persist data with Redis

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

Page 13: How to persist data with Redis

NOW WHAT

• Data needs to save to

disk

• UI needs help

Page 14: How to persist data with Redis

I'M FLYING AWAY

FROM YOU PEOPLE

But more on that next week