Not sure what happened there, too early in the morning for me and I must have pressed the wrong button.
In answer to your direct question.
1. We read in existing files when we start Redis up as Redis acts as a persistent store.
2. We setup redis to read from the beanstalkd queues. Once these queues are running, point 1 becomes moot.
3. We then send things out to our users. Looking at the code to do this specifically, it looks pretty simple code, we last updated it 7th march 2016 so its not something we touch very often (if at all).
We have a JSON structure to hold four different types of data we send down, output_short_json is JSON data field holding traffic updates, its around 40K of data, analytics_json is a load of analytics stuff we send down, around 30K once per day. jamcams and speedcams are simple GPS chunks of data sent down every 72 hours or so.
The code is here (almost verbatim).
io.on('connection', function (socket) {
var now = moment().format('HH:mm:ss DD/MM/YYYY');
else
console.log("[" + now + "] Socket.io: Connection made socketId='" +
socket.id + "'");
allClients.push(socket);
// On first connection we send ALL the cached files down to the client.
for (var key in redisConfig)
{
// Send down ALL the cached files (if we have any) so the client is up to date.
if (redisConfig[key].cache)
{
var now = moment().format('HH:mm:ss DD/MM/YYYY');
if (redisConfig[key].debug)
console.log("[" + now + "] Updating client with cached '" + key + "' cache=" + redisConfig[key].cache);
else
console.log("[" + now + "] Updating client with cached '" + key + "'");
io.emit(key , { Data: redisConfig[key].cache , queue: key });
} else
{
console.log("[" + now + "] Updating client with cached '" + key + "' cache=EMPTY");
}
}
console.log("");
socket.on('output_short_json', function (valueName , setValueResult) {
if (redisConfig["output_short_json"].cache)
{
setValueResult({
success : true ,
data : redisConfig["output_short_json"].cache
});
} else
{
setValueResult({
success : false ,
message : "Unable to retrieve file"
});
}
});
socket.on('disconnect', function () {
var now = moment().format('HH:mm:ss DD/MM/YYYY');
else
console.log("[" + now + "] Socket.io: disconnect socketId='" +
socket.id + "'");
console.log("[" + now + "] Got disconnect! " +
socket.id);
var i = allClients.indexOf(socket);
allClients.splice(i, 1);
});
});
Thats about it.