diff --git a/package-lock.json b/package-lock.json index cdef5b8eced..f9ae8ece3aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "parse-server", - "version": "4.3.0", + "name": "@hustle/parse-server", + "version": "4.3.0-hustle4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 31dc6225d78..ebb674acbc9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hustle/parse-server", - "version": "4.3.0-fast-roles-dedupe", + "version": "4.3.0-hustle4", "description": "An express module providing a Parse-compatible API server", "main": "lib/index.js", "repository": { diff --git a/src/Adapters/Cache/FrozenCacheAdapter.js b/src/Adapters/Cache/FrozenCacheAdapter.js new file mode 100644 index 00000000000..edb52576a49 --- /dev/null +++ b/src/Adapters/Cache/FrozenCacheAdapter.js @@ -0,0 +1,30 @@ +export class FrozenCacheAdapter { + constructor() { + this.cache = {}; + } + + get(key) { + const record = this.cache[key]; + if (!record) { + return Promise.resolve(null); + } + return Promise.resolve(record); + } + + // eslint-disable-next-line no-unused-vars + put(key, value, ttl) { + this.cache[key] = value; + return Promise.resolve(); + } + + del(key) { + delete this.cache[key]; + return Promise.resolve(); + } + + clear() { + return Promise.resolve(); + } +} + +export default FrozenCacheAdapter; diff --git a/src/Config.js b/src/Config.js index 214e22ca57d..27af7a0f412 100644 --- a/src/Config.js +++ b/src/Config.js @@ -29,7 +29,7 @@ export class Config { Object.keys(cacheInfo).forEach(key => { if (key == 'databaseController') { const schemaCache = new SchemaCache( - cacheInfo.cacheController, + cacheInfo.schemaCacheController, cacheInfo.schemaCacheTTL, cacheInfo.enableSingleSchemaCache ); @@ -114,7 +114,9 @@ export class Config { } static validateIdempotencyOptions(idempotencyOptions) { - if (!idempotencyOptions) { return; } + if (!idempotencyOptions) { + return; + } if (idempotencyOptions.ttl === undefined) { idempotencyOptions.ttl = IdempotencyOptions.ttl.default; } else if (!isNaN(idempotencyOptions.ttl) && idempotencyOptions.ttl <= 0) { diff --git a/src/Controllers/index.js b/src/Controllers/index.js index 5bbd9308f17..cd4e69e755d 100644 --- a/src/Controllers/index.js +++ b/src/Controllers/index.js @@ -21,6 +21,7 @@ import SchemaCache from './SchemaCache'; import { GridFSBucketAdapter } from '../Adapters/Files/GridFSBucketAdapter'; import { WinstonLoggerAdapter } from '../Adapters/Logger/WinstonLoggerAdapter'; import { InMemoryCacheAdapter } from '../Adapters/Cache/InMemoryCacheAdapter'; +import { FrozenCacheAdapter } from '../Adapters/Cache/FrozenCacheAdapter'; import { AnalyticsAdapter } from '../Adapters/Analytics/AnalyticsAdapter'; import MongoStorageAdapter from '../Adapters/Storage/Mongo/MongoStorageAdapter'; import PostgresStorageAdapter from '../Adapters/Storage/Postgres/PostgresStorageAdapter'; @@ -39,6 +40,7 @@ export function getControllers(options: ParseServerOptions) { pushWorker, } = getPushController(options); const cacheController = getCacheController(options); + const schemaCacheController = getSchemaCacheController(options); const analyticsController = getAnalyticsController(options); const liveQueryController = getLiveQueryController(options); const databaseController = getDatabaseController(options, cacheController); @@ -59,6 +61,7 @@ export function getControllers(options: ParseServerOptions) { pushControllerQueue, analyticsController, cacheController, + schemaCacheController, parseGraphQLController, liveQueryController, databaseController, @@ -126,6 +129,12 @@ export function getUserController(options: ParseServerOptions): UserController { }); } +export function getSchemaCacheController(options: ParseServerOptions) { + const { appId } = options; + const cacheAdapter = new FrozenCacheAdapter(); + return new CacheController(cacheAdapter, appId); +} + export function getCacheController( options: ParseServerOptions ): CacheController {