Skip to content

Commit

Permalink
Exporting cache functions; adding check for valid member data before …
Browse files Browse the repository at this point in the history
…attempting to cache gists.
  • Loading branch information
josiahp committed Jul 15, 2014
1 parent 45656d0 commit f270907
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var redis = require('redis'),
rsub = redis.createClient(),
docstore = redis.createClient();

console.log('Loading configuration...');
var config = require('./codelove-community.json');

rsub.subscribe('codelove-community');
Expand All @@ -31,8 +30,9 @@ function scheduleCacheGists() {
rpub.publish('codelove-community', 'cacheGists');
};

setInterval(scheduleCacheUsers, 5000);
setInterval(scheduleCacheGists, 5000);
module.exports.scheduleCacheGists = scheduleCacheGists;
module.exports.scheduleCacheUsers = scheduleCacheUsers;


function cacheUsers() {
console.log('executing cacheUsers');
Expand Down Expand Up @@ -66,6 +66,11 @@ function cacheGists() {
gists = [ ];

docstore.get('codelove-community.members', function(err, data) {
if (!data) {
docstore.set('codelove-community.gists', '', redis.print);
return;
}

members = JSON.parse(data);
function nextMember(i) {
var member = members[i];
Expand Down

0 comments on commit f270907

Please sign in to comment.