Skip to content

Instantly share code, notes, and snippets.

@frankpinto
Created November 15, 2012 20:54
Show Gist options
  • Save frankpinto/4081201 to your computer and use it in GitHub Desktop.
Save frankpinto/4081201 to your computer and use it in GitHub Desktop.
Remove fetchnow articles from cache
var mongo = require('onswipe-shared').mongo();
var redis = require('./lib/redis'); // From Synapse
if (process.argv.length > 2)
{
var entriesCollection = mongo.collection('entries');
pid = parseInt(process.argv[2]);
entriesCollection.find({publisher_id: pid, source_id: null}, function(err, entries) {
if (err) {
console.log(err);
process.exit(1);
}
console.log('Publisher has', entries.length, 'fetchnow articles.');
var removed = 0;
entries.forEach(function(entry) {
redis.del('synapse:entryCache:' + entry.synapse_uuid, function(err, reply) {
if (reply)
removed++;
});
});
console.log(removed.toString(), 'of the fetchnow articles existed in the cache. They have been removed.');
redis.quit();
mongo.close();
});
}
else
console.log('Please provide a pid as a command line argument');
/* Output:
* Publisher has 48 fetchnow articles.
* 0 of the fetchnow articles existed in the cache. They have been removed.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment