Meteor.setInterval on server side, Performance? -
i looking way clean of database entries might not need after 24hours or that, looking meteor code: https://github.com/meteor/meteor/blob/832e6fe44f3635cae060415d6150c0105f2bf0f6/packages/oauth/pending_credentials.js
i found part:
// periodically clear old entries never retrieved var _cleanstaleresults = function() { // remove credentials older 1 minute var timecutoff = new date(); timecutoff.setminutes(timecutoff.getminutes() - 1); oauth._pendingcredentials.remove({ createdat: { $lt: timecutoff } }); }; var _cleanuphandle = meteor.setinterval(_cleanstaleresults, 60 * 1000);
i couldn't find exectuion of function. wondering if var _cleanuphandle
means execute every 60 seconds? , if it's seems strange endless function run every 60 seconds? might general javascript question trying understand performance of kind of thing , if can safely re use technique? main goal store temporary data on server , remove after it's not needed.
i recommend using task queue library such https://atmospherejs.com/percolate/synced-cron.
for approach, specify task , start it. can end task whenever want. note server-side.
adding task
syncedcron.add({ name: 'crunch important numbers marketing department', schedule: function(parser) { // parser later.parse object. note specify frequency return parser.text('every 2 hours'); }, job: function() { var numberscrunched = crushsomenumbers(); return numberscrunched; } });
starting tasks
syncedcron.start();
stopping tasks
syncedcron.stop()
there lot more options recommend checking out documentation.
Comments
Post a Comment