Extracted cache adapter base class to external package

https://github.com/TryGhost/Toolbox/issues/364

- When the adapter base class lives deep inside Ghost's codebase it is pretty hard for other developers to extend it. With the goal of making Ghost easier to use and deploy by others, this kind of functionality should be as easy to extend as possible.
- The base adapters should live in the TryGhost/SDK repository. Next ones to move are Scheduling, SSO, and Storage base adapters.
This commit is contained in:
Naz 2022-09-09 12:36:37 +08:00
parent 2cc5c15ca4
commit ff5919e86c
No known key found for this signature in database
5 changed files with 8 additions and 14 deletions

View File

@ -1,12 +0,0 @@
class Cache {
constructor() {
Object.defineProperty(this, 'requiredFns', {
// NOTE: "keys" method is only here to provide smooth migration from deprecated "getAll" method
// once use of "getAll" is eradicated, can also remove the "keys" method form the interface
value: ['get', 'set', 'reset', 'keys'],
writable: false
});
}
}
module.exports = Cache;

View File

@ -1,4 +1,4 @@
const Base = require('./Base');
const Base = require('@tryghost/adapter-base-cache');
class MemoryCache extends Base {
constructor() {

View File

@ -15,7 +15,7 @@ const adapterManager = new AdapterManager({
adapterManager.registerAdapter('storage', require('ghost-storage-base'));
adapterManager.registerAdapter('scheduling', require('../../adapters/scheduling/SchedulingBase'));
adapterManager.registerAdapter('sso', require('../../adapters/sso/Base'));
adapterManager.registerAdapter('cache', require('../../adapters/cache/Base'));
adapterManager.registerAdapter('cache', require('@tryghost/adapter-base-cache'));
module.exports = {
/**

View File

@ -53,6 +53,7 @@
},
"dependencies": {
"@sentry/node": "7.12.1",
"@tryghost/adapter-base-cache": "0.1.0",
"@tryghost/adapter-manager": "0.0.0",
"@tryghost/admin-api-schema": "4.1.1",
"@tryghost/api-framework": "0.0.0",

View File

@ -3173,6 +3173,11 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==
"@tryghost/adapter-base-cache@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@tryghost/adapter-base-cache/-/adapter-base-cache-0.1.0.tgz#b0bce0dc45b1fe4a3e93950ffadaa833148f4994"
integrity sha512-jKCJ4E3yu2BZ8H/FGhIUYyd2p3NchJOXTazyuXSrZT3fKbJTC8rbaYmJNmE0u6JiojLZpEHhGJnlU8VlLUWaFw==
"@tryghost/admin-api-schema@4.1.1":
version "4.1.1"
resolved "https://registry.yarnpkg.com/@tryghost/admin-api-schema/-/admin-api-schema-4.1.1.tgz#9165dce1c40a340fa446b5e9f08ee467f3c0e7f6"