0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

Moved cache initialization behind the hostSetting

refs https://github.com/TryGhost/Toolbox/issues/515

- By moving the cache initialization behind the hostSettings configuration we can limit the experimental feature to only hosted environments with special capacities
- An example configuration to enable Tags caching looks like this:
```
    "hostSettings": {
        "tagsPublicCache": {
            "enabled": true
        },
```
In addition to have the caching backed by a Redis backend or even InMemoryTTL cache the site configuration should include a cache adapter configuration like this:
```
    "adapters": {
        "cache": {
            "active": "Memory",
            "tagsPublic": {
                "adapter": "TTL",
                "ttl": 60000 // 60 * 1000 minute
            },
```
This commit is contained in:
Naz 2023-02-10 20:01:20 +08:00 committed by naz
parent 5216220541
commit 9d4ea7b8c9

View file

@ -8,8 +8,13 @@ class TagsPublicServiceWrapper {
// Wire up all the dependencies
const models = require('../../models');
const adapterManager = require('../adapter-manager');
const config = require('../../../shared/config');
let tagsCache;
if (config.get('hostSettings:tagsPublicCache:enabled')) {
tagsCache = adapterManager.getAdapter('cache:tagsPublic');
}
const tagsCache = adapterManager.getAdapter('cache:tagsPublic');
const {TagsPublicRepository} = require('@tryghost/tags-public');
this.linkRedirectRepository = new TagsPublicRepository({