mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
cache categories:cid and cid:<cid>:children
these rarely change, no need to go to db for them
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var db = require('../database');
|
||||
|
||||
var categories = require('../categories');
|
||||
var privileges = require('../privileges');
|
||||
var user = require('../user');
|
||||
@@ -21,7 +21,7 @@ SocketCategories.get = function (socket, data, callback) {
|
||||
isAdmin: async.apply(user.isAdministrator, socket.uid),
|
||||
categories: function (next) {
|
||||
async.waterfall([
|
||||
async.apply(db.getSortedSetRange, 'categories:cid', 0, -1),
|
||||
async.apply(categories.getAllCidsFromSet, 'categories:cid'),
|
||||
async.apply(categories.getCategoriesData),
|
||||
], next);
|
||||
},
|
||||
@@ -139,7 +139,7 @@ SocketCategories.getMoveCategories = function (socket, data, callback) {
|
||||
categories: function (next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, next);
|
||||
categories.getAllCidsFromSet('categories:cid', next);
|
||||
},
|
||||
function (cids, next) {
|
||||
categories.getCategories(cids, socket.uid, next);
|
||||
@@ -183,7 +183,7 @@ function ignoreOrWatch(fn, socket, cid, callback) {
|
||||
user.isAdminOrGlobalModOrSelf(socket.uid, targetUid, next);
|
||||
},
|
||||
function (next) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, next);
|
||||
categories.getAllCidsFromSet('categories:cid', next);
|
||||
},
|
||||
function (cids, next) {
|
||||
categories.getCategoriesFields(cids, ['cid', 'parentCid'], next);
|
||||
|
||||
Reference in New Issue
Block a user