fix timeouts on category.purge when there are 20k groups

v1.18.x
Barış Soner Uşaklı 8 years ago
parent 7a6b685aa0
commit 0b3656f34c

@ -58,7 +58,7 @@ module.exports = function (Categories) {
], next);
},
function (next) {
async.each(privileges.privilegeList, function (privilege, next) {
async.eachSeries(privileges.privilegeList, function (privilege, next) {
groups.destroy('cid:' + cid + ':privileges:' + privilege, next);
}, next);
},

@ -4,6 +4,7 @@ var async = require('async');
var plugins = require('../plugins');
var utils = require('../utils');
var db = require('./../database');
var batch = require('../batch');
module.exports = function (Groups) {
Groups.destroy = function (groupName, callback) {
@ -30,14 +31,14 @@ module.exports = function (Groups) {
async.apply(db.delete, 'group:' + groupName + ':owners'),
async.apply(db.deleteObjectField, 'groupslug:groupname', utils.slugify(groupName)),
function (next) {
db.getSortedSetRange('groups:createtime', 0, -1, function (err, groups) {
if (err) {
return next(err);
}
async.each(groups, function (group, next) {
db.sortedSetRemove('group:' + group + ':members', groupName, next);
}, next);
});
batch.processSortedSet('groups:createtime', function (groupNames, next) {
var keys = groupNames.map(function (group) {
return 'group:' + group + ':members';
});
db.sortedSetsRemove(keys, groupName, next);
}, {
batch: 500,
}, next);
},
], function (err) {
if (err) {

Loading…
Cancel
Save