From 3df43dc5317c3f5e4a5b0aa6502251bd72de26a3 Mon Sep 17 00:00:00 2001 From: dblythy Date: Sun, 11 Jun 2023 15:48:44 +1000 Subject: [PATCH 1/3] Update ParseServer.js --- src/ParseServer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ParseServer.js b/src/ParseServer.js index 6465e1f3c9..73d10f8303 100644 --- a/src/ParseServer.js +++ b/src/ParseServer.js @@ -92,10 +92,10 @@ class ParseServer { const { databaseController, hooksController, + cacheController, cloud, security, schema, - cacheAdapter, liveQueryController, } = this.config; try { @@ -110,8 +110,11 @@ class ParseServer { if (schema) { startupPromises.push(new DefinedSchemas(schema, this.config).execute()); } - if (cacheAdapter?.connect && typeof cacheAdapter.connect === 'function') { - startupPromises.push(cacheAdapter.connect()); + if ( + cacheController.adapter?.connect && + typeof cacheController.adapter.connect === 'function' + ) { + startupPromises.push(cacheController.adapter.connect()); } startupPromises.push(liveQueryController.connect()); await Promise.all(startupPromises); From 4fd714ef2f5104fc0d30a1db6c9add155ef3e754 Mon Sep 17 00:00:00 2001 From: dblythy Date: Sun, 25 Jun 2023 20:47:26 +1000 Subject: [PATCH 2/3] add test --- spec/RedisCacheAdapter.spec.js | 14 ++++++++++++++ src/TestUtils.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/RedisCacheAdapter.spec.js b/spec/RedisCacheAdapter.spec.js index 3fd6f32dde..8cb3d9d48f 100644 --- a/spec/RedisCacheAdapter.spec.js +++ b/spec/RedisCacheAdapter.spec.js @@ -167,4 +167,18 @@ describe_only(() => { .then(() => expect(getQueueCount(cache)).toEqual(0)) .then(done); }); + + it('should start and connect cache adapter', async () => { + const server = await reconfigureServer({ + cacheAdapter: { + module: __dirname.replace('/spec', '') + '/lib/Adapters/Cache/RedisCacheAdapter', + options: { + url: 'redis://127.0.0.1:6379/1', + }, + }, + }); + const symbol = Object.getOwnPropertySymbols(server.config.cacheController); + const client = server.config.cacheController[symbol[0]].client; + expect(client.isOpen).toBeTrue(); + }); }); diff --git a/src/TestUtils.js b/src/TestUtils.js index 3d5133556d..6d4cfb0f14 100644 --- a/src/TestUtils.js +++ b/src/TestUtils.js @@ -13,7 +13,7 @@ export function destroyAllDataPermanently(fast) { Object.keys(AppCache.cache).map(appId => { const app = AppCache.get(appId); const deletePromises = []; - if (app.cacheAdapter) { + if (app.cacheAdapter && app.cacheAdapter.clear) { deletePromises.push(app.cacheAdapter.clear()); } if (app.databaseController) { From 2706d26ea9bdd4b33ab6471b68d27ec53761dae7 Mon Sep 17 00:00:00 2001 From: dblythy Date: Sun, 25 Jun 2023 20:48:06 +1000 Subject: [PATCH 3/3] Update RedisCacheAdapter.spec.js --- spec/RedisCacheAdapter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/RedisCacheAdapter.spec.js b/spec/RedisCacheAdapter.spec.js index 8cb3d9d48f..9b88e857c4 100644 --- a/spec/RedisCacheAdapter.spec.js +++ b/spec/RedisCacheAdapter.spec.js @@ -171,7 +171,7 @@ describe_only(() => { it('should start and connect cache adapter', async () => { const server = await reconfigureServer({ cacheAdapter: { - module: __dirname.replace('/spec', '') + '/lib/Adapters/Cache/RedisCacheAdapter', + module: `${__dirname.replace('/spec', '')}/lib/Adapters/Cache/RedisCacheAdapter`, options: { url: 'redis://127.0.0.1:6379/1', },