Created
November 15, 2012 20:54
-
-
Save frankpinto/4081201 to your computer and use it in GitHub Desktop.
Remove fetchnow articles from cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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