diff --git a/public/language/en-GB/admin/advanced/cache.json b/public/language/en-GB/admin/advanced/cache.json index 6d290e9112..9ca1b983fb 100644 --- a/public/language/en-GB/admin/advanced/cache.json +++ b/public/language/en-GB/admin/advanced/cache.json @@ -4,6 +4,7 @@ "group-cache": "Group Cache", "local-cache": "Local Cache", "object-cache": "Object Cache", + "notification-cache": "Notification Cache", "percent-full": "%1% Full", "post-cache-size": "Post Cache Size", "items-in-cache": "Items in Cache" diff --git a/src/controllers/admin/cache.js b/src/controllers/admin/cache.js index f46d7fd41e..5c5d71c42b 100644 --- a/src/controllers/admin/cache.js +++ b/src/controllers/admin/cache.js @@ -10,6 +10,7 @@ cacheController.get = async function (req, res) { const groupCache = require('../../groups').cache; const { objectCache } = require('../../database'); const localCache = require('../../cache'); + const { delayCache } = require('../../notifications'); const uptimeInSeconds = process.uptime(); function getInfo(cache) { return { @@ -32,6 +33,7 @@ cacheController.get = async function (req, res) { post: postCache, group: groupCache, local: localCache, + notification: delayCache, }; if (objectCache) { caches.object = objectCache; diff --git a/src/notifications.js b/src/notifications.js index 6aa5088594..374aec988c 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -30,6 +30,8 @@ const notificationCache = ttlCache({ dispose: sendEmail, }); +Notifications.delayCache = notificationCache; + Notifications.baseTypes = [ 'notificationType_upvote', 'notificationType_new-topic', diff --git a/src/socket.io/admin/cache.js b/src/socket.io/admin/cache.js index 65ddfbefe1..2ac786c7a8 100644 --- a/src/socket.io/admin/cache.js +++ b/src/socket.io/admin/cache.js @@ -6,13 +6,7 @@ const db = require('../../database'); const plugins = require('../../plugins'); SocketCache.clear = async function (socket, data) { - let caches = { - post: require('../../posts/cache').getOrCreate(), - object: db.objectCache, - group: require('../../groups').cache, - local: require('../../cache'), - }; - caches = await plugins.hooks.fire('filter:admin.cache.get', caches); + const caches = await getAvailableCaches(); if (!caches[data.name]) { return; } @@ -20,15 +14,20 @@ SocketCache.clear = async function (socket, data) { }; SocketCache.toggle = async function (socket, data) { - let caches = { - post: require('../../posts/cache').getOrCreate(), - object: db.objectCache, - group: require('../../groups').cache, - local: require('../../cache'), - }; - caches = await plugins.hooks.fire('filter:admin.cache.get', caches); + const caches = await getAvailableCaches(); if (!caches[data.name]) { return; } caches[data.name].enabled = data.enabled; }; + +async function getAvailableCaches() { + const caches = { + post: require('../../posts/cache').getOrCreate(), + object: db.objectCache, + group: require('../../groups').cache, + local: require('../../cache'), + notification: require('../../notifications').delayCache, + }; + return await plugins.hooks.fire('filter:admin.cache.get', caches); +} \ No newline at end of file diff --git a/src/views/admin/advanced/cache.tpl b/src/views/admin/advanced/cache.tpl index a4964c742b..d19b9acd39 100644 --- a/src/views/admin/advanced/cache.tpl +++ b/src/views/admin/advanced/cache.tpl @@ -9,66 +9,64 @@ - -
- {{{ each caches }}} -
-
-
-
-
-
- +
+
+ + + + + + + + + + + + + + + + + {{{ each caches }}} + + + + + + + + + + + + {{{ end }}} - {{{ if (@key == "post") }}} -
-
- - -
- {{{ end }}} - - + +
capacitycountsizehitsmisseshit ratiohits/secttl
+
+
+ +
+ [[admin/advanced/cache:{@key}-cache]]
- [[admin/advanced/cache:{@key}-cache]] - -
- - -
- - -
-
-
- [[admin/advanced/cache:percent-full, {./percentFull}]] -
-
+
{./percentFull}%{{{if ./length}}}{./length}{{{else}}}{./itemCount}{{{end}}} + {{{ if (@key == "post") }}} +
+ -
- {{{if ./length}}}{./length}{{{else}}}{./itemCount}{{{end}}} / {{{if ./max}}}{./max}{{{else}}}{./maxSize}{{{end}}} -
+ -
- {./hits} -
-
- {./misses} -
-
- {./hitRatio} -
-
- {./hitsPerSecond} -
- - {{{ if ./ttl }}} -
- {./ttl} -
+
+ {{{ else }}} + {{{if ./max}}}{./max}{{{else}}}{./maxSize}{{{end}}} + {{{ end }}} +
{./hits}{./misses}{./hitRatio}{./hitsPerSecond}{./ttl} +
+ + +
+
-
- {{{ end }}}